home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / util / misc / zshell27src.lha / ZShell27 / ZShell.S < prev   
Text File  |  1995-08-16  |  243KB  |  12,160 lines

  1.  
  2. ****************************************************
  3. *********  ZSHELL (C) 1990,91 Paul Hayter  *********
  4. ********  updated to V2.7 by Martin Gierich ********
  5. ********    First major change: 08.06.93    ********
  6. *********    Last change: 14.08.95       *********
  7. ****************************************************
  8.  
  9. **ZShell V2.7.2, Changes since V2.6:
  10. *more than 64K Review-Buffer possible
  11. *MORE: N searches next
  12. *STDERR provided
  13. *PROTECT + - = ,reduced disk access
  14. *GURU 16: Could not set up pipe task
  15. *GURU 21: Unexpected close-window
  16. *GURU 22: Forbid or Disable state
  17. *FLAG CHECK ON: count locks -> LOCATE
  18. *MAKELINK: default HARD
  19. *DELETE dir ALL: tries to remove dir
  20. *Pipes: FLAGS PIPE,
  21. *Reads from stdin: MORE, TYPE, HTYPE, STRINGS, SEARCH, EXECUTE ZSHELL
  22. *EXECUTE [ZSHELL] filename
  23. *RUN outputs to current window or to redirected output
  24. *>w redirects to default window description
  25. *EVAL: &=and !=or ==poke ?=peek
  26. *ASCII-to-num: ^=load file !=bptr2aptr &=aptr2bptr $=hex %=bin
  27. *(KILL command uses pr_ExitCode)
  28. *(COMPARE source dest [offset1 offset2])
  29.  
  30. ;DEBUG    = 1
  31. ;KILL    = 1
  32.  
  33. ***        TABSIZE = 8 Chars         ***
  34. ***     Local Labels named .A to .Z         ***
  35.  
  36. VERSION            equ    $1234
  37.  
  38. FLcheck        =0
  39. FLmatch        =1
  40. FLappicon    =2
  41. FLwild        =3
  42. FLerrors    =4
  43. FLdebug        =5
  44. FLcutline    =6
  45. FLall        =7
  46. FLhide        =8
  47. FLpipe        =9
  48. MaxFlags     =10
  49.  
  50. FIB            equ    260        ;FileInfoBlock
  51. ACCESS_READ        equ    -2
  52. ACCESS_WRITE        equ    -1
  53. MODE_READWRITE        equ    1004
  54. MODE_OLDFILE        equ    1005
  55. MODE_NEWFILE        equ    1006
  56.  
  57. SIGBREAKB_CTRL_C    equ    $C
  58. SIGBREAKB_CTRL_D    equ    $D
  59. SIGBREAKB_CTRL_E    equ    $E
  60. SIGBREAKB_CTRL_F    equ    $F
  61.  
  62. eb_CoolCapture    equ    46
  63. eb_ColdCapture    equ    42
  64. eb_WarmCapture    equ    50
  65. eb_KickMemPtr    equ    546
  66. eb_KickTagPtr    equ    550
  67. eb_KickCheckSum    equ    554
  68.     
  69. * FILE INFO BLOCK
  70. fib_DiskKey        equ  $0000
  71. fib_DirEntryType    equ  $0004
  72. fib_FileName        equ  $0008
  73. fib_Protection        equ  $0074
  74. fib_EntryType        equ  $0078
  75. fib_Size        equ  $007c
  76. fib_NumBlocks        equ  $0080
  77. fib_Date        equ  $0084
  78. fib_Comment        equ  $0090
  79. fib_Reserved        equ  $00e0
  80.  
  81. * INFO DATA STRUCTURE
  82. id_NumSoftErrors    equ    0
  83. id_UnitNumber        equ    4
  84. id_DiskState        equ    8
  85. id_NumBlocks        equ    12
  86. id_NumBlocksUsed    equ    16
  87. id_BytesPerBlock    equ    20
  88. id_DiskType        equ    24
  89. id_VolumeNode        equ    28
  90. id_InUse        equ    32
  91.  
  92. * TASK
  93. tc_State        equ    15
  94. tc_SigWait        equ    22
  95.  
  96. * PROCESS
  97.  
  98. pr_MsgPort        equ    92
  99. pr_SegList        equ    128
  100. pr_StackSize        equ    132
  101. pr_GlobVec        equ    136
  102. pr_TaskNum        equ    140
  103. pr_StackBase        equ    144
  104. pr_Result2        equ    148
  105. pr_CurrentDir        equ    152
  106. pr_CIS            equ    156
  107. pr_COS            equ    160
  108. pr_ConsoleTask        equ    164
  109. pr_FileSystemTask    equ    168
  110. pr_CLI            equ    172
  111. pr_ReturnAddr        equ    176
  112. pr_PktWait        equ    180
  113. pr_WindowPtr        equ    184
  114. pr_HomeDir        equ    188    KS2
  115. pr_Flags        equ    192
  116. pr_ExitCode        equ    196
  117. pr_ExitData        equ    200
  118. pr_CES            equ    224
  119.  
  120. * COMMAND LINE INTERFACE
  121. cli_Result        equ    0
  122. cli_SetName        equ    4
  123. cli_CommandDir        equ    8
  124. cli_ReturnCode        equ    12
  125. cli_CommandName        equ    16
  126. cli_FailLevel        equ    20
  127. cli_Prompt        equ    24
  128. cli_StandardInput    equ    28
  129. cli_CurrentInput    equ    32
  130. cli_CommandFile        equ    36
  131. cli_Interactive        equ    40
  132. cli_Background        equ    44
  133. cli_CurrentOutput    equ    48
  134. cli_DefaultStack    equ    52
  135. cli_StandardOutput    equ    56
  136. cli_Module        equ    60
  137.  
  138. * FILE HANDLE
  139. fh_Link            equ    0
  140. fh_Port            equ    4
  141. fh_Type            equ    8
  142. fh_Buf            equ    12
  143. fh_Pos            equ    16
  144. fh_End            equ    20
  145.  
  146. * FILE LOCK
  147. fl_Link            equ    0
  148. fl_Key            equ    4
  149. fl_Access        equ    8
  150. fl_Task            equ    12
  151. fl_Volume        equ    16
  152.  
  153. * DATESTAMP
  154. ds_Days            equ    0
  155. ds_Minute        equ    4
  156. ds_Tick            equ    8
  157.  
  158. RETURN_OK        EQU  0
  159. RETURN_WARN        EQU  5
  160. RETURN_ERROR        EQU  10
  161. RETURN_BAD        EQU  15
  162. RETURN_FAIL        EQU  20
  163.  
  164. *Assign Stuff
  165. dl_Root        equ    34    APTR
  166. rn_Info        equ    24    BPTR
  167. rn_Flags    equ    52    LONG
  168. di_DevInfo    equ    4    BPTR
  169. di_NetHand    equ    16    BPTR
  170. dvi_Next    equ    0    BPTR
  171. dvi_Type    equ    4    LONG
  172. dvi_Task    equ    8    APTR
  173. dvi_Lock    equ    12    BPTR
  174. dvi_Handler    equ    16    (PathPtr)
  175. dvi_StackSize    equ    20
  176. dvi_LockList    equ    20
  177. dvi_Priority    equ    24
  178. dvi_Startup    equ    28
  179. dvi_SegList    equ    32
  180. dvi_GlobVec    equ    36
  181. dvi_Name    equ    40    BSTR
  182. dlt_device    equ    0    <-- contents of dvi_Type
  183. dlt_directory    equ    1
  184. dlt_volume    equ    2
  185. dlt_late    equ    3
  186. dlt_nonbind    equ    4
  187.  
  188. *Resident Stuff
  189. resi_link    equ    0    ;BPTR
  190. resi_usecount    equ    4    ;LONG
  191. resi_seglist    equ    8    ;BPTR
  192. resi_name    equ    12    ;BSTR
  193. resi_length    equ    4+4+4
  194.  
  195. *Icon Lib Stuff
  196. sm_Process    equ    $14
  197. sm_Segment    equ    $18
  198. sm_NumArgs    equ    $1c
  199. sm_ToolWindow    equ    $20
  200. sm_ArgList    equ    $24
  201. wa_Lock        equ    0
  202. wa_Name        equ    4
  203. do_Magic    equ    0    ;must be $e310
  204. do_Type        equ    $30
  205. do_ToolTypes    equ    $36
  206. do_ToolWindow    equ    $46
  207. do_StackSize    equ    $4a
  208.  
  209. *WAppMessage
  210. am_Type        equ    20
  211. am_NumArgs    equ    30
  212. am_ArgList    equ    34
  213.  
  214. * AVAIL STUFF
  215. MEMF_PUBLIC        equ 1
  216. MEMF_CHIP        equ 2
  217. MEMF_FAST        equ 4
  218. MEMF_CLEAR        equ $10000
  219. MEMF_LARGEST        equ $20000
  220.  
  221. * ACTIONS
  222. ACTION_SCREEN_MODE    EQU    994
  223. ACTION_INHIBIT        EQU    31
  224. ACTION_MORE_CACHE    EQU    18
  225. ACTION_RENAME_DISK    EQU    9
  226. ACTION_DIE        EQU    5
  227. ACTION_DISK_CHANGE    EQU    33
  228. ACTION_SET_DATE        EQU    34
  229. ACTION_DISK_INFO    EQU    25
  230. ACTION_WRITE_PROTECT    EQU    1023
  231. ACTION_FLUSH        EQU    27
  232. ACTION_READ        EQU    "R"
  233. ACTION_WRITE        EQU    "W"
  234.  
  235. dp_Link        EQU  $00   ;DosPacket Structure
  236. dp_Port        EQU  $04
  237. dp_Type        EQU  $08
  238. dp_Arg1        EQU  $14
  239. dp_SIZEOF    EQU  $30
  240.  
  241. sp_Msg        EQU  $00   ;StandardPacket Structure
  242. sp_Pkt        EQU  $14
  243. sp_SIZEOF    EQU  $44
  244.  
  245. LH_HEAD        equ    0
  246. LH_TAIL        equ    4
  247. LH_TAILPRED    equ    8
  248. LH_TYPE        equ    12
  249. LH_PAD        equ    13
  250. LH_SIZE        equ    14
  251.  
  252. LN_SUCC        equ    0
  253. LN_PRED        equ    4
  254. LN_TYPE        equ    8
  255. LN_PRI        equ    9
  256. LN_NAME        equ    10
  257. LN_SIZE        equ    14
  258.  
  259. NT_MSGPORT    EQU  4
  260.  
  261. MP_FLAGS    EQU  $0E   ;Message Port Structure
  262. MP_SIGBIT    EQU  $0F   ;Signal bit number
  263. MP_SIGTASK    EQU  $10   ;Task to be signalled
  264. MP_MSGLIST    EQU  $14   ;Message linked list
  265. MP_SIZE        EQU  $22
  266.  
  267. mn_ReplyPort    equ    14
  268. mn_Length    equ    18
  269. mn_Size        equ    20
  270.  
  271. PA_SIGNAL    EQU  0       ;PutAction messages
  272.  
  273.     
  274. * LIBRARY CALLS
  275. * EXEC
  276. _LVOOpenLibrary        equ    -552
  277. _LVOOldOpenLibrary    equ    -408
  278. _LVOCloseLibrary    equ    -414
  279. _LVOSetFunction        equ    -420
  280. _LVOAllocMem        equ    -198
  281. _LVOFreeMem        equ    -210
  282. _LVORawDoFmt        equ    -522
  283. _LVORawMayGetChar    equ    -510
  284. _LVOFindTask        equ    -294
  285. _LVOSetTaskPri        equ    -300
  286. _LVOAddTask        equ    -282
  287. _LVORemTask        equ    -288
  288. _LVOForbid        equ    -132
  289. _LVOPermit        equ    -138
  290. _LVOAvailMem        equ    -216
  291. _LVOAddPort        equ    -354
  292. _LVORemPort        equ    -360
  293. _LVOFindPort        equ    -390
  294. _LVOPutMsg        equ    -366
  295. _LVOGetMsg        equ    -372
  296. _LVOReplyMsg        equ    -378
  297. _LVOWaitPort        equ    -384
  298. _LVOWait        equ    -318
  299. _LVOSignal        equ    -324
  300. _LVOSetSignal        equ    -306
  301. _LVOAllocSignal        equ    -330
  302. _LVOFreeSignal        equ    -336
  303. _LVOOpenDev        equ    -444
  304. _LVOCloseDev        equ    -450
  305. _LVODoIO        equ    -456
  306. _LVOCreateMsgPort    equ    -666    KS 2.0+
  307. _LVODeleteMsgPort    equ    -672
  308.  
  309. * DOS
  310. _LVOSetProtection    equ    -186
  311. _LVOExecute        equ    -222
  312. _LVOOutput        equ    -60
  313. _LVOWrite        equ    -48
  314. _LVOLock        equ    -84
  315. _LVOUnLock        equ    -90
  316. _LVODupLock        equ    -96
  317. _LVOExamine        equ    -102
  318. _LVOExNext        equ    -108
  319. _LVOOpen        equ    -30
  320. _LVOClose        equ    -36
  321. _LVORead        equ    -42
  322. _LVOInput        equ    -54
  323. _LVODeleteFile        equ    -72
  324. _LVORename        equ    -78
  325. _LVOCreateDir        equ    -120
  326. _LVOCurrentDir        equ    -126
  327. _LVOIoErr        equ    -132
  328. _LVOParentDir        equ    -210
  329. _LVOLoadSeg        equ    -150
  330. _LVOUnLoadSeg        equ    -156
  331. _LVOCreateProc        equ    -138
  332. _LVOInfo        equ    -114
  333. _LVODateStamp        equ    -192
  334. _LVOSeek        equ    -66
  335. _LVODeviceProc        equ    -174
  336. _LVODelay        equ    -198
  337. _LVOSetComment        equ    -180
  338. _LVOIsInteractive    equ    -216
  339. _LVOReadLink        equ    -438    KS 2.0+
  340. _LVOMakeLink        equ    -444
  341. _LVOFault        equ    -468
  342. _LVOPrintFault        equ    -474
  343. _LVOAssignLock        equ    -612
  344. _LVOAssignLate        equ    -618
  345. _LVOAssignPath        equ    -624
  346. _LVOAssignAdd        equ    -630
  347. _LVORemAssignList    equ    -636
  348. _LVOFormat        equ    -714
  349. _LVOAddBuffers        equ    -732
  350. _LVOFilePart        equ    -870
  351. _LVOPathPart        equ    -876
  352. _LVOInhibit        equ    -726
  353. _LVOParsePatternNC    equ    -966
  354. _LVOMatchPatternNC    equ    -972
  355. _LVONameFromLock    equ    -402
  356.  
  357. *Intuition
  358. _LVOPrintIText        equ    -216
  359. _LVODisplayAlert    equ    -90
  360. _LVODisplayBeep        equ    -96
  361. _LVOLockIBase        equ    -414
  362. _LVOUnlockIBase        equ    -420
  363. _LVORefreshWindowFrame    equ    -456
  364. _LVOSizeWindow        equ    -288
  365. _LVOMoveWindow        equ    -168
  366. _LVOActivateWindow    equ    -450
  367. _LVORemakeDisplay    equ    -384
  368. _LVOMakeScreen        equ    -378
  369. _LVORethinkDisplay    equ    -390
  370. _LVOCloseScreen        equ    -66
  371. _LVOOpenScreenTagList    equ    -612    KS2.0+
  372. _LVOPubScreenStatus    equ    -552
  373.  
  374. *Icon
  375. _LVOGetDiskObject    equ    -78
  376. _LVOGetDefDiskObject    equ    -120
  377. _LVOPutDiskObject    equ    -84
  378. _LVOFreeDiskObject    equ    -90
  379. _LVOFindToolType    equ    -96
  380. _LVOMatchToolValue    equ    -102
  381.  
  382. *Workbench
  383. _LVOAddAppIconA        equ    -60    KS2.0+
  384. _LVOAddAppWindowA    equ    -48
  385. _LVORemoveAppIcon    equ    -66
  386. _LVORemoveAppWindow    equ    -54
  387. _LVOWBInfo        equ    -90
  388.  
  389. *Utility
  390. _LVOToUpper        equ    -174    KS2.0+
  391. _LVOStricmp        equ    -162
  392.  
  393. *Asl
  394. _LVOAllocFileRequest    equ    -30    KS2.0+
  395. _LVOFreeFileRequest    equ    -36
  396. _LVORequestFile        equ    -42
  397.  
  398. *XPKMaster
  399. _LVOXpkExamine        equ    -36
  400. _LVOXpkUnpack        equ    -48
  401.  
  402. *AmigaGuide
  403. _LVOOpenAmigaGuideA    equ    -54
  404. _LVOCloseAmigaGuide    equ    -66
  405.  
  406.  
  407. rf_File        = 4
  408. rf_Dir        = 8
  409.  
  410. XPK_InName    = $80005851    filename
  411. XPK_OutName    = $80005860    filename
  412. XPK_GetError    = $80005875    buffer
  413. XPK_TaskPri    = $8000587f    ubyte
  414.  
  415.         RSRESET
  416. ;NewAmigaGuide-structure
  417. nag_Lock    RS.L    1
  418. nag_Name    RS.L    1
  419. nag_Screen    RS.L    1
  420. nag_PubScreen    RS.L    1
  421. nag_HostPort    RS.L    1
  422. nag_ClientPort    RS.L    1
  423. nag_BaseName    RS.L    1
  424. nag_Flags    RS.L    1
  425. nag_Context    RS.L    1
  426. nag_Node    RS.L    1
  427. nag_Line    RS.L    1
  428. nag_Extens    RS.L    1
  429. nag_Client    RS.L    1
  430. NewAmigaGuide_SIZEOF    RS.W    0
  431.  
  432. * DOS LIBRARY
  433. dl_A2            equ    42
  434.  
  435. *SYSTEM0 stuff!!!!!!!!!!
  436. REG_SysBase    equr a6
  437.  
  438. callsys    macro
  439.     jsr _LVO\1(REG_SysBase)
  440.     endm
  441.  
  442. * parameter offsets & stack
  443. ;SAVED_REGS    reg    a2-a6/d2-d3
  444. DELTA        equ    7*4
  445. ARG_NAME    equ    4+DELTA
  446. ARG_SEGLIST    equ    8+DELTA
  447. ARG_ARGS    equ    12+DELTA
  448.  
  449. * additional return codes
  450. NO_CLI        equ    -1
  451. NO_MEM        equ    -2
  452.  
  453. * local constants
  454. MAXBSTR        equ    255
  455. LF        equ    10
  456.  
  457. * register usage
  458. REG_Result    equr    d3
  459. REG_Process    equr    a2      ;may not be A4, see below!
  460. REG_CLI        equr    a3
  461. REG_CIS        equr    a4      ;may not be A3, see below!
  462. REG_PrevStack    equr    a1    ;V2.0 changed from a5 to a1
  463.  
  464. * local stack frame
  465. * STRUCTURE      StackFrame,0
  466.         RSRESET
  467. sf_CommandName    RS.B    MAXBSTR+1        ;BSTR, length byte!
  468. sf_CommandArgs    RS.B    MAXBSTR+1        ;not a BSTR, LF-terminated!
  469. sf_PrevStack        RS.L    1
  470. sf_SaveReturnAddr    RS.L    1
  471. sf_SaveModule        RS.L    1
  472. sf_SaveCommandName    RS.L    1
  473. sf_StackBase    RS.L    1
  474. sf_StackSize    RS.L    1
  475. sf_PushSize    RS.L    1
  476. sf_Process    RS.L    1
  477. sf_CLI        RS.L    1
  478. sf_CIS        RS.L    1
  479. sf_SCB_Buf    RS.L    1
  480. sf_SCB_Pos    RS.L    1
  481. sf_SCB_End    RS.L    1
  482. sf_Membase    RS.L    1
  483. sf_SIZEOF    RS.W    0
  484.  
  485. *Constants (only LONGS!)
  486. SHELLINE_SIZE    equ    256    V1.30
  487. CLIBUF_SIZE    equ    256
  488. NEWPRINTSIZE    equ    200
  489. HISTORY_SIZE    equ    1024    MUST BE POWER OF 2
  490.  
  491. * THE GENERAL MEMORY BLOCK (LONGS!)
  492.         RSRESET
  493. blockbase    RS.B    260    the fib or info goes here
  494. sp_node        RS.B    14    DOSpacket
  495. sp_reply    RS.L    1
  496. sp_length    RS.W    1
  497. sp_link        RS.L    1
  498. sp_port        RS.L    1
  499. packettype    RS.L    1
  500. sp_res1        RS.L    1
  501. sp_res2        RS.L    1
  502. myArg1        RS.L    1
  503. myArg2        RS.L    1
  504. myArg3        RS.L    1
  505. myArg4        RS.L    1
  506. myArg5        RS.L    1
  507. myArg6        RS.L    1
  508. myArg7        RS.L    1
  509. packettask    RS.L    1
  510. devproc        RS.L    1    endofpacket
  511. x1        RS.L    1
  512. last_failcode    RS.L    1
  513. outhandle    RS.L    1
  514. inhandle    RS.L    1
  515. x2        RS.B    40
  516. x3        RS.B    40
  517. stdout        RS.L    1
  518. stdin        RS.L    1
  519. EntryA0        RS.L    1
  520. better_Seglist    RS.L    1
  521. parm1        RS.L    1    addr of each parameter within shelline
  522. parm2        RS.L    1
  523. parm3        RS.L    1
  524. parm4        RS.L    1
  525. parm5        RS.L    1
  526. parm6        RS.L    1
  527. parm7        RS.L    1
  528. parm8        RS.L    1
  529. parm9        RS.L    1
  530. parm10        RS.B    4*16    16 extra parms
  531. endofparms    RS.L    1    for NULL end
  532. x4
  533. shelline    RS.B    SHELLINE_SIZE
  534. endofshelline
  535. CLIbuf        RS.B    CLIBUF_SIZE
  536. NewPrintBuffer    RS.B    NEWPRINTSIZE
  537. errorstack    RS.L    1
  538. topstack    RS.L    1
  539. stacksize    RS.L    1
  540. temp1        RS.L    1
  541. temp2        RS.L    1
  542. temp3        RS.L    1
  543. temp4        RS.L    1
  544. tempbuf        RS.B    2*SHELLINE_SIZE    double shellinesizebuffer
  545. temp2buf    RS.B    80    80 char temp buffer
  546. dosbase        RS.L    1
  547. intuibase    RS.L    1
  548. Result2        RS.L    1
  549. kickver        RS.W    1
  550. old_prompt    RS.L    1
  551. old_setname    RS.L    1
  552. old_homedir    RS.L    1
  553. redirect_in    RS.B    1
  554. redirect_out    RS.B    1
  555. CLIptr        RS.L    1
  556. Flags        RS.L    1
  557. prompt_cr    RS.L    1
  558. ConsoleSwitch    RS.L    1
  559. count_line    RS.L    1
  560. FNCignore    RS.B    30    for filenamecompletition
  561. FNCvolume    RS.L    1
  562. FNCkey        RS.L    1
  563. FNCdate        RS.L    1
  564. FNCsize        RS.L    1
  565. FNCbuffer    RS.L    1
  566. FNCcycle    RS.L    1
  567. FNCfill        RS.W    1
  568. FNCbuffered    RS.B    1
  569. FNCchars    RS.B    1
  570. x5        RS.W    1
  571. OldCTask    RS.L    1
  572. OldCIS        RS.L    1
  573. OldCOS        RS.L    1
  574. bordersize    RS.L    1
  575. scsize        RS.L    1
  576. scaddr        RS.L    1
  577. scptr        RS.L    1
  578. scflag        RS.B    1
  579. openwin_flag    RS.B    1
  580. noresi_flag    RS.B    1
  581. noreview_flag    RS.B    1
  582. ReviewMem    RS.L    1
  583. ReviewPtr    RS.L    1
  584. ReviewSize    RS.L    1
  585. gather_ptr    RS.L    1
  586. tempbytes    RS.W    1
  587. gather        RS.B    80    for CSI string and error-string
  588. pipe_in        RS.B    14
  589. pipe_out    RS.B    14
  590. PipeTask    RS.L    1
  591. x6        RS.B    8
  592. morekeys    RS.B    20
  593. dotchar        RS.B    1
  594. ctrl_codes    RS.B    29    Keyboard-CTRL-Codes
  595. CDbackstr    RS.B    80    string of last directory
  596. now        RS.L    1
  597. nost        RS.L    1
  598. then        RS.L    1
  599. past        RS.B    HISTORY_SIZE    history buffer=1024 bytes
  600. thistask    RS.L    1
  601. x7        RS.B    46
  602. first_set_defn    RS.L    1
  603. MPipePtr    RS.L    1
  604. app_name    RS.L    1
  605. wbbase        RS.L    1
  606. copysize    RS.L    1
  607. temp5        RS.L    1
  608. temp6        RS.L    1
  609. temp7        RS.L    1
  610. appwinport    RS.L    1
  611. appwindow    RS.L    1
  612. pubscreen    RS.L    1
  613. pubname        RS.L    1
  614. windowptr    RS.L    1
  615. utilbase    RS.L    1
  616. online_help    RS.L    1
  617. windowname    RS.L    1
  618. mem_addr    RS.L    1
  619. wild_flag    RS.B    1
  620. x8        RS.B    1
  621. wild_string    RS.B    80    allow 80 chars for wildcard
  622. date_mark    RS.L    3    3 lwords
  623. mem_mark    RS.L    3    3 lwords chip/fast/total
  624. CD_string    RS.B    80    Allow 80 bytes.
  625. prompt_string    RS.B    80    Allow 80 bytes.
  626. prompt_args    RS.B    40    Allow 40 bytes
  627. line_count    RS.W    1
  628. mult_comm_ptr    RS.L    1
  629. pipe_comm_ptr    RS.L    1
  630. pipe_count    RS.B    1
  631. break_flag    RS.B    1
  632. cd_block    RS.L    1
  633. cd_volnode    RS.L    1
  634. recurs_flag    RS.W    1
  635. indent_count    RS.W    1
  636. resi_flag    RS.B    1
  637. forcediskflag    RS.B    1
  638. CLIflag        RS.B    1
  639. WBflag        RS.B    1
  640. oldwindowptr    RS.L    1
  641. wb_msg        RS.L    1
  642. iconbase    RS.L    1
  643. diskobj        RS.L    1
  644. filesys_old    RS.L    1
  645. cdir_old    RS.L    1
  646. x9        RS.B    20
  647. if_flag        RS.B    1
  648. if_condition    RS.B    1
  649. goto_flag    RS.B    1
  650. memclk_flag    RS.B    1
  651. dest_label    RS.B    60
  652. x10        RS.L    1
  653. mem_offset_addr    RS.L    1
  654. io_Message    RS.B    20    io-request (timer)
  655. io_Device    RS.L    1
  656. io_Unit        RS.L    1
  657. io_Command    RS.W    1
  658. io_Flags    RS.B    1
  659. io_Error    RS.B    1
  660. tv_secs        RS.L    1
  661. tv_micro    RS.L    1
  662. io_pad        RS.L    2    ;don't remove
  663. sizeofblk    RS.W    0
  664.  
  665.  
  666.  
  667. ********************************************
  668.  
  669. ;    SECTION    MYSHELL,CODE
  670.     
  671. ;Try to open dos then do the shell
  672. start    moveq    #-1,d7
  673.     move.l    a0,a3
  674.     move.l    4.w,a6
  675.     move.l    #sizeofblk,d0
  676.     move.l    #1+1<<16,d1        "memf_public" & clear it
  677.     jsr    _LVOAllocMem(a6)    alloc general mem block
  678.     tst.l    d0
  679.     beq    blkfail
  680.     move.l    d0,a5            A5=MEMBASE
  681.     move.l    sp,topstack(a5)
  682.     move.l    a3,EntryA0(a5)
  683.     move.w    20(a6),kickver(a5)        Kickstart-Version
  684.     lea    intuiname(pc),a1
  685.     jsr    _LVOOldOpenLibrary(a6)
  686.     tst.l    d0
  687.     beq    intfail
  688.     move.l    d0,intuibase(a5)
  689.     lea    dosname(pc),a1
  690.     jsr    _LVOOldOpenLibrary(a6)
  691.     tst.l    d0
  692.     beq    dosfail
  693.     move.l    d0,dosbase(a5)
  694.     clr.w    CLIflag(a5)        delete CLI&WBflag
  695.     sub.l    a1,a1
  696.     jsr    _LVOFindTask(a6)
  697.     move.l    d0,thistask(a5)        save this task address
  698.     move.l    d0,a2
  699.     move.l    pr_CLI(a2),d0
  700.     bne.s    .A
  701.     subq.w    #1,CLIflag(a5)        WB-Start (set CLI&WBflag)
  702.     lea    pr_MsgPort(a2),a0
  703.     IFND    DEBUG
  704.     jsr    _LVOWaitPort(a6)
  705.     ENDC
  706.     IFD    DEBUG
  707.     moveq    #-1,d0
  708. .AA    move.l    #1,d1
  709.     dbra    d0,.AA
  710.     ENDC
  711.     lea    pr_MsgPort(a2),a0
  712.     jsr    _LVOGetMsg(a6)
  713.     move.l    d0,wb_msg(a5)
  714.     beq.s    .C
  715.     move.l    d0,a0
  716.     clr.l    sm_Segment(a0)        Clear Seg-Descriptor
  717. .C    move.l    pr_StackSize(a2),stacksize(a5)
  718.     move.l    pr_SegList(a2),d0
  719.     beq.s    .B
  720.     lsl.l    #2,d0
  721.     move.l    d0,a0
  722.     clr.l    12(a0)            Clear SegPointer
  723.     bra.s    .B
  724. .A    lsl.l    #2,d0            CLI-Start
  725.     move.l    d0,a2
  726.     move.l    cli_DefaultStack(a2),d0
  727.     lsl.l    #2,d0
  728.     move.l    d0,stacksize(a5)    save stacksize
  729.     clr.l    cli_Module(a2)        do not free seglist
  730.     cmp.b    #"r",1(a3)
  731.     bne.s    .B
  732.     addq.b    #1,noresi_flag(a5)
  733. .B    move.l    dosbase(a5),a6        A6=DOSBASE
  734.     tst.b    noresi_flag(a5)
  735.     bne.s    doIT
  736.     lea    ZShellName(pc),a4
  737.     bsr    search_res2
  738.     lea    start-4(pc),a1
  739.     tst.l    d0
  740.     IFD    DEBUG
  741.     bra.s    doIT
  742.     ENDC
  743.     beq.s    cresi
  744.     lsl.l    #2,d0
  745.     move.l    d0,a2
  746.     nop
  747.     nop
  748. VCheck    cmp.w    #VERSION,VCheck-start+6(a2)
  749.     bne.w    normex
  750.     addq.l    #1,resi_usecount(a0)
  751.     cmp.l    a1,a2
  752.     beq.s    doIT        running as resident
  753.     jmp    JumpIn-start+4(a2) Jump to JumpIn, but in the resident Code
  754. JumpIn    move.l    a1,d1    here it arrives
  755.     lsr.l    #2,d1
  756.     jsr    _LVOUnLoadSeg(a6)    free old mem
  757.     bra.s    doIT
  758. cresi    move.l    a1,d3
  759.     lsr.l    #2,d3
  760.     bsr    create_resi    make zshell resident
  761.     bne    crfail
  762.     addq.l    #1,resi_usecount(a2)
  763. doIT    bsr    shell            ***    DO IT    ***
  764.     bsr    deallocate_sets
  765.     bsr    reviewend
  766.     bsr    KillAppWin
  767.     bsr    FreeFNC
  768.     moveq    #1,d1
  769.     bsr    OutputCLInum
  770.     bsr    RemoveCLI
  771.     lea    start-4(pc),a0
  772.     move.l    a0,d6
  773.     lsr.l    #2,d6
  774.     tst.b    noresi_flag(a5)
  775.     bne.s    normex
  776.     lea    ZShellName(pc),a4
  777.     bsr    search_res2
  778.     tst.l    d0
  779.     beq.s    crfail
  780.     subq.l    #1,resi_usecount(a0)
  781.     tst.l    d7
  782.     bne.s    crfail
  783.     moveq    #1,d1
  784.     cmp.l    resi_usecount(a0),d1
  785.     bne.s    crfail
  786.     move.l    d0,d6    kill the ZShell-Resident
  787.     move.l    a0,a2
  788.     move.l    d2,a0
  789.     move.l    resi_link(a2),resi_link(a0)
  790.     clr.l    resi_link(a2)
  791.     move.l    a2,d1
  792.     lsr.l    #2,d1
  793.     jsr    _LVOUnLoadSeg(a6)
  794. normex    bsr    giveman        free manualmem
  795.     move.l    thistask(a5),a0
  796.     tst.b    CLIflag(a5)    How to UnLoad the Segment
  797.     beq.s    .A
  798.     move.l    pr_SegList(a0),d0
  799.     beq.s    .B
  800.     lsl.l    #2,d0
  801.     move.l    d0,a0
  802.     move.l    d6,12(a0)    Store Segment in SegPointer (WB/RUN)
  803. .B    move.l    wb_msg(a5),d0
  804.     beq.s    crfail
  805.     move.l    d0,a0
  806.     move.l    d6,sm_Segment(a0)    and in Seg-Descriptor    (WB)
  807.     bra.s    crfail
  808. .A    move.l    pr_CLI(a0),a0
  809.     add.l    a0,a0
  810.     add.l    a0,a0
  811.     move.l    d6,cli_Module(a0)    Store Segment in Module    (CLI)
  812. crfail    move.l    dosbase(a5),a1
  813.     move.l    4.w,a6
  814.     jsr    _LVOCloseLibrary(a6)
  815. dosfail    move.l    intuibase(a5),a1
  816.     jsr    _LVOCloseLibrary(a6)
  817. intfail    move.l    wb_msg(a5),d2
  818.     move.l    a5,a1
  819.     move.l    #sizeofblk,d0
  820.     jsr    _LVOFreeMem(a6)
  821.     tst.l    d2
  822.     beq.s    .A
  823.     jsr    _LVOForbid(a6)    (what for ?)
  824.     move.l    d2,a1        WB-Message
  825.     jmp    _LVOReplyMsg(a6)    never returns !
  826. .A    moveq    #0,d0
  827.     rts
  828. blkfail    moveq    #RETURN_ERROR,d0
  829.     rts
  830.  
  831. *********************************
  832. *    MAIN BIT        *
  833. *********************************
  834. shell    move.l    sp,errorstack(a5)
  835.     IFD    KILL
  836.     cmp.w    #36,kickver(a5)
  837.     blo.s    .D
  838.     move.l    thistask(a5),a3
  839.     lea    CleanUp(pc),a0
  840.     move.l    a0,pr_ExitCode(a3)
  841.     move.l    a5,pr_ExitData(a3)
  842. .D    ENDC
  843.     move.l    4.w,a6
  844.     lea    utilname(pc),a1
  845.     moveq    #37,d0
  846.     jsr    _LVOOpenLibrary(a6)
  847.     move.l    d0,utilbase(a5)
  848.     move.l    dosbase(a5),a6
  849.     bsr    CreateCLI
  850.     bne    cloga            exit on error
  851.     move.l    thistask(a5),a3
  852.     move.l    pr_CLI(a3),a2
  853.     add.l    a2,a2
  854.     add.l    a2,a2
  855.     move.l    a2,CLIptr(a5)
  856.     move.l    cli_Prompt(a2),old_prompt(a5)
  857.     lea    prompt_args(a5),a0
  858.     move.l    a0,d0
  859.     lsr.l    #2,d0
  860.     move.l    d0,cli_Prompt(a2)
  861.     move.l    cli_SetName(a2),old_setname(a5)
  862.     lea    CD_string(a5),a0
  863.     move.l    a0,d0
  864.     lsr.l    #2,d0
  865.     move.l    d0,cli_SetName(a2)
  866.     cmp.w    #36,kickver(a5)
  867.     blo.s    .C
  868.     move.l    pr_HomeDir(a3),old_homedir(a5)
  869.     clr.l    pr_HomeDir(a3)
  870.     move.l    dl_Root(a6),a0
  871.     bset    #24,rn_Flags(a0)    set wildstar flag
  872.     bsr    InitAppWin
  873.     tst.l    pr_CES(a3)
  874.     bne.s    .C
  875.     jsr    _LVOOutput(a6)
  876.     move.l    d0,pr_CES(a3)
  877. .C    jsr    _LVOOutput(a6)    SAVE THE CONSOLE HANDLERS
  878.     move.l    d0,outhandle(a5)
  879.     move.l    d0,stdout(a5)
  880.     jsr    _LVOInput(a6)
  881.     move.l    d0,inhandle(a5)
  882.     move.l    d0,stdin(a5)
  883.     bsr    GetWindowPtr
  884.     beq.s    .A
  885.     move.l    d0,windowptr(a5)
  886.     move.l    d0,pr_WindowPtr(a3)
  887. .A    tst.b    WBflag(a5)
  888.     bne.s    notini        0=WB/1=newcli/2=run/3=pipe
  889.     bsr    initialise_default
  890. notini    moveq    #0,d1
  891.     bsr    OutputCLInum
  892.     tst.b    CLIflag(a5)
  893.     beq.s    .A
  894.     cmp.b    #2,WBflag(a5)
  895.     bhs.s    .A
  896.     moveq    #-127,d0
  897.     subq.l    #2,d0
  898.     bsr    GetMessage    Welcome-Message
  899.     lea    pr_TaskNum(a3),a1
  900.     bsr    new_print
  901. .A    bsr    eval_CD
  902.     IFND    DEBUG
  903.     bsr    execscr    
  904.     ENDC
  905. chorus    bsr    CheckForbid    HERE BEGINS THE MAIN LOOP
  906.     bsr    close_redirection
  907.     bsr    raw_on        MAKE SURE RAW MODE IS ON
  908.     clr.b    noreview_flag(a5)
  909.     bsr    compose_prompt
  910.     bsr    get_line
  911.     clr.b    break_flag(a5)
  912.     move.l    4.w,a6
  913.     moveq    #0,d0        clear signals c&d
  914.     moveq    #0,d1
  915.     bset    #SIGBREAKB_CTRL_C,d1
  916.     bset    #SIGBREAKB_CTRL_D,d1
  917.     jsr    _LVOSetSignal(a6)
  918.     move.l    dosbase(a5),a6
  919.     clr.b    forcediskflag(a5)
  920.     move.l    parm1(a5),a0
  921.     move.b    (a0),d0
  922.     cmp.b    dotchar(a5),d0
  923.     bne.s    .A
  924.     addq.l    #1,a0
  925.     tst.b    (a0)
  926.     bne.s    .B
  927.     tst.l    parm2(a5)
  928.     bne.s    .B
  929.     lea    CDbackstr(a5),a0    dir back
  930.     bsr    chdir
  931.     bra.s    chorus
  932. .B    move.l    a0,parm1(a5)
  933.     addq.b    #1,forcediskflag(a5)
  934.     bra    notfound    force disk-command
  935. .A    cmp.b    #"#",(a0)    #-sign for ;#comment
  936.     beq    chorus
  937.     move.l    a0,d7        check for ? (help sign)
  938.     tst.b    1(a0)
  939.     bne.s    .C
  940.     cmp.b    #"?",(a0)
  941.     bne.s    .C
  942.     bsr    help_man    ? as command
  943.     bra    chorus
  944. .C    lea    comtext(pc),a1
  945.     lea    comoffs(pc),a2
  946. mtch    bsr    match
  947.     tst.l    d0
  948.     beq.s    notfound
  949.     move.l    parm1(a5),d7        check for ? (help sign)
  950.     move.l    parm2(a5),a1
  951.     tst.b    1(a1)
  952.     bne.s    .D
  953.     cmp.b    #"?",(a1)
  954.     bne.s    .D
  955.     bsr    rawh_off
  956.     bsr    help_man    ? as arg
  957.     bra    chorus
  958. .D    move.l    sp,errorstack(a5)    important in scripts ?
  959.     lea    start(pc),a0
  960. intern    jsr    0(a0,d0.w)    call internal command
  961.     tst.b    break_flag(a5)
  962.     bne.s    com_break
  963. chkfail    move.l    d0,last_failcode(a5)
  964.     move.l    CLIptr(a5),a0
  965.     cmp.l    cli_FailLevel(a0),d0    ALL COMMANDS MUST RETURN D0=0 unless failure
  966.     blo    chorus
  967. com_fail move.l    d0,-(sp)
  968.     bsr    close_redirection    additional for pipes
  969.     move.l    #-154,d0
  970.     bsr    GetMessage        Fail Level
  971.     move.l    sp,a1
  972.     bsr    new_print
  973.     move.l    (sp)+,d0
  974. com_break bsr    kill_script
  975.     bra    chorus
  976. notfound bsr    archie3        TRY DISK
  977.     move.l    d0,-(sp)
  978.     move.l    thistask(a5),a0
  979.     move.l    cd_volnode(a5),d0
  980.     move.l    pr_CurrentDir(a0),a1
  981.     add.l    a1,a1
  982.     add.l    a1,a1
  983.     cmp.l    fl_Volume(a1),d0    check volume node
  984.     bne.s    .A
  985.     move.l    cd_block(a5),d0
  986.     cmp.l    fl_Key(a1),d0    check disk block number
  987.     beq.s    .B
  988. .A    bsr    eval_CD        If command changes cd then change prompt.
  989. .B    move.l    (sp)+,d0
  990.     bra.s    chkfail
  991.  
  992.     
  993. *Match the string pointed to by A0 to one in a table pted to by a1
  994. *The number of the matched string is linked to an offset table pted to by
  995. *A2.  return with 
  996. *D0 holding offset from 'start' so a jsr 0(a0,d0.w) can be done
  997. *Entry    A1 pts to Command text table  A2 pts to command offset table
  998.  
  999. match    moveq    #0,d1    command count
  1000.     move.l    a0,a3    save command
  1001. mat2    move.b    (a0)+,d0
  1002.     bset    #5,d0
  1003.     cmp.b    dotchar(a5),d0    check "."
  1004.     bne.s    .A
  1005.     tst.b    (a0)
  1006.     beq.s    foundit    shortcut
  1007. .A    move.b    (a1),d2
  1008.     bset    #5,d2
  1009.     cmp.b    d2,d0
  1010.     bne.s    nextcom    if any character wrong then check next
  1011.     addq.l    #1,a1
  1012.     tst.b    -1(a0)    check whether 0 was last compared
  1013.     beq.s    foundit    if it was then success
  1014.     bra.s    mat2
  1015. nextcom    tst.b    (a1)+
  1016.     bne.s    nextcom
  1017.     addq.l    #2,d1    each offset is a word
  1018.     move.l    a3,a0
  1019.     tst.b    (a1)    put 0,0 at end of com table
  1020.     bne.s    mat2
  1021.     moveq    #0,d0    D0 = 0 if command not found
  1022.     rts
  1023. foundit    move.w    0(a2,d1.l),d0    get offset
  1024.     rts
  1025.  
  1026.  
  1027. *********************************************
  1028. ZShellName    dc.b    "ZShell",0
  1029. dosname        dc.b    "dos.library",0
  1030. intuiname    dc.b    "intuition.library",0
  1031.  
  1032.     dc.b    "$VER: "
  1033. helptx1 dc.b    "ZShell 2.7 (14.08.95)",10
  1034.     dc.b    "(C)1990,91 Paul Hayter (V1.3); "
  1035.     dc.b    "Updated 1993-95 by Martin Gierich.",10
  1036.     dc.b    "Freeware, NO commercial usage !",10
  1037.     dc.b    "Please send your comments to"
  1038.     dc.b    " uj3w@rz.uni-karlsruhe.de",10,10
  1039.     dc.b    "Commands:",0
  1040. helptx2 dc.b    10,"Options:",10
  1041.     dc.b    "-r (recursive): Copy,Delete,Dir,Join,List,Move,Protect",10
  1042.     dc.b    "-c (clear): Avail,Endcli,Locate,Path,Resident,Run",10
  1043.     dc.b    "-q (quick): Dir,List,Delete",10,10
  1044.     dc.b    "Editing: (SHIFT+) Cursor, <-, DEL,"
  1045.     dc.b    " (SHIFT+) TAB, ESC and see CONFIG CTRLKEYS",10
  1046.     dc.b    ". for dir back, force disk or abbreviation",10
  1047.     dc.b    "Type 'help ?' for more help.",0
  1048. helptx3
  1049.  
  1050. comtext    dc.b    'AddBuffers',0    V1.27
  1051.     dc.b    'Alias',0
  1052.     dc.b    'Ask',0        V1.28
  1053.     dc.b    'Assign',0
  1054.     dc.b    'Avail',0
  1055.     dc.b    'Border',0    V2.0
  1056.     dc.b    'Break',0    V2.0
  1057.     dc.b    'CD',0
  1058.     dc.b    'Cls',0        V2.0
  1059.     dc.b    'Config',0    V2.0
  1060.     dc.b    'Copy',0
  1061.     dc.b    'Date',0
  1062.     dc.b    'Delete',0
  1063.     dc.b    'Dir',0
  1064.     dc.b    'DiskChange',0    V2.0
  1065.     dc.b    'Echo',0
  1066. elsetx    dc.b    'Else',0    V1.28
  1067. endcltx    dc.b    'EndCLI',0
  1068. endiftx dc.b    'EndIf',0    V1.28
  1069.     dc.b    'Eval',0
  1070. exectx    dc.b    'Execute',0
  1071.     dc.b    'FailAt',0
  1072.     dc.b    'Fault',0    V2.0
  1073.     dc.b    'FileNote',0    V2.0
  1074.     dc.b    'Flags',0    V2.3
  1075.     dc.b    'GetMsg',0    V2.0
  1076.     dc.b    'Help',0
  1077.     dc.b    'HType',0    V1.29
  1078.     dc.b    'If',0        V1.28
  1079.     dc.b    'Info',0
  1080.     dc.b    'Join',0    V1.29
  1081.     dc.b    'Kill',0    V2.0
  1082. labeltx dc.b    'Lab',0        V1.29
  1083.     dc.b    'List',0
  1084.     dc.b    'Locate',0    V2.0
  1085.     dc.b    'Lock',0    V2.0
  1086.     dc.b    'M',0
  1087.     dc.b    'MakeDir',0
  1088.     dc.b    'MakeIcon',0    V2.3
  1089.     dc.b    'MakeLink',0    V2.3
  1090. clktask    dc.b    'MemClk',0    V2.0
  1091.     dc.b    'More',0    V1.23
  1092.     dc.b    'Move',0    V2.3
  1093.     dc.b    'NewCLI',0    V2.0
  1094.     dc.b    'Path',0
  1095.     dc.b    'Prompt',0
  1096.     dc.b    'Protect',0
  1097.     dc.b    'PutMsg',0    V2.0
  1098.     dc.b    'Quit',0    V1.29
  1099.     dc.b    'Relabel',0    V1.27
  1100.     dc.b    'Rename',0
  1101.     dc.b    'Resident',0    V1.25
  1102.     dc.b    'Review',0    V2.1
  1103.     dc.b    'Run',0        V2.2
  1104.     dc.b    'Search',0    V2.0
  1105.     dc.b    'SetClock',0    V2.0
  1106.     dc.b    'SetDate',0    V2.0
  1107.     dc.b    'Show',0    V2.0
  1108.     dc.b    'Skip',0
  1109.     dc.b    'Split',0    V2.6
  1110.     dc.b    'Stack',0
  1111.     dc.b    'Strings',0    V1.29
  1112.     dc.b    'TaskPri',0    V2.0
  1113.     dc.b    'Type',0
  1114.     dc.b    'UnAlias',0
  1115.     dc.b    'Wait',0
  1116.     dc.b    0
  1117.     even    
  1118.  
  1119. comoffs
  1120.     dc.w    addbuffersz-start
  1121.     dc.w    set_funcz-start    ;alias
  1122.     dc.w    askz-start
  1123.     dc.w    assignz-start
  1124.     dc.w    availz-start
  1125.     dc.w    borderz-start
  1126.     dc.w    breakz-start
  1127.     dc.w    cdz-start
  1128.     dc.w    clsz-start
  1129.     dc.w    configz-start
  1130.     dc.w    copyz-start
  1131.     dc.w    datez-start
  1132.     dc.w    deletez-start
  1133.     dc.w    dirz-start
  1134.     dc.w    diskchangez-start
  1135.     dc.w    echoz-start
  1136.     dc.w    elsez-start
  1137.     dc.w    endcliz-start
  1138.     dc.w    endifz-start
  1139.     dc.w    evalz-start
  1140.     dc.w    executez-start
  1141.     dc.w    failatz-start
  1142.     dc.w    faultz-start
  1143.     dc.w    filenotez-start
  1144.     dc.w    flagsz-start
  1145.     dc.w    getmsgz-start
  1146.     dc.w    helpz-start
  1147.     dc.w    htypez-start
  1148.     dc.w    ifz-start
  1149.     dc.w    infoz-start
  1150.     dc.w    joinz-start
  1151.     dc.w    killz-start
  1152.     dc.w    labelz-start    ;lab
  1153.     dc.w    listz-start
  1154.     dc.w    locatez-start
  1155.     dc.w    lockz-start
  1156.     dc.w    memexamz-start    ;m
  1157.     dc.w    makedirz-start
  1158.     dc.w    makeiconz-start
  1159.     dc.w    makelinkz-start
  1160.     dc.w    memclkz-start
  1161.     dc.w    morez-start
  1162.     dc.w    movez-start
  1163.     dc.w    newcliz-start
  1164.     dc.w    pathz-start
  1165.     dc.w    promptz-start
  1166.     dc.w    protectz-start
  1167.     dc.w    putmsgz-start
  1168.     dc.w    quitz-start
  1169.     dc.w    relabelz-start
  1170.     dc.w    renamez-start
  1171.     dc.w    residentz-start
  1172.     dc.w    reviewz-start
  1173.     dc.w    runz-start
  1174.     dc.w    searchz-start
  1175.     dc.w    setclockz-start
  1176.     dc.w    setdatez-start
  1177.     dc.w    showz-start
  1178.     dc.w    skipz-start
  1179.     dc.w    splitz-start
  1180.     dc.w    stackz-start
  1181.     dc.w    stringsz-start
  1182.     dc.w    taskpriz-start
  1183.     dc.w    typez-start
  1184.     dc.w    unsetz-start    ;unalias
  1185.     dc.w    waitz-start
  1186.  
  1187.  
  1188. **********************************************************
  1189. initialise_default
  1190.     move.l    CLIptr(a5),a0
  1191.     moveq    #16,d0
  1192.     move.l    d0,cli_FailLevel(a0)
  1193.     move.b    #LF,past(a5)
  1194.     lea    prompt_args_tx(pc),a0    init prompt
  1195.     lea    prompt_args(a5),a1
  1196. .C    move.b    (a0)+,(a1)+
  1197.     bne.s    .C
  1198.     moveq    #ctrl_inite-ctrl_init-1,d0
  1199.     lea    ctrl_init(pc),a0
  1200.     lea    ctrl_codes-1(a5),a1
  1201. .B    move.b    (a0)+,(a1)+        init ctrl-codes and dotchar
  1202.     dbra    d0,.B
  1203.     moveq    #more_inite-more_init-1,d0
  1204.     lea    more_init(pc),a0
  1205.     lea    morekeys(a5),a1
  1206. .A    move.b    (a0)+,(a1)+        init keys for MORE
  1207.     dbra    d0,.A
  1208.     lea    appicontx(pc),a0
  1209.     move.l    a0,app_name(a5)
  1210.     lea    helpman(pc),a0
  1211.     move.l    a0,online_help(a5)
  1212.     move.l    #%1111001010,Flags(a5)
  1213.     move.l    #50000,copysize(a5)
  1214.     move.l    #4000,FNCsize(a5)
  1215.     rts
  1216.  
  1217. InitAppWin
  1218.     tst.l    ConsoleSwitch(a5)    test noraw-mode
  1219.     beq.s    .A
  1220.     move.l    4.w,a6
  1221.     jsr    _LVOCreateMsgPort(a6)    get msg-port
  1222.     move.l    d0,appwinport(a5)
  1223.     beq.s    .A
  1224.     move.l    d0,a2
  1225.     move.l    dosbase(a5),a6
  1226.     bsr    GetWindowPtr        get ptr to window
  1227.     move.l    d0,d2
  1228.     beq.s    .A
  1229.     bsr    OpenWBLib
  1230.     beq    .A
  1231.     moveq    #0,d0
  1232.     moveq    #0,d1
  1233.     move.l    d2,a0
  1234.     sub.l    a1,a1
  1235.     exg.l    a1,a2
  1236.     jsr    _LVOAddAppWindowA(a6)    make appwin
  1237.     move.l    d0,appwindow(a5)
  1238. .A    move.l    dosbase(a5),a6
  1239.     rts
  1240.  
  1241. GetWindowPtr    ;pointer to Console-Window to a0 (0 for fail)
  1242.     move.l    thistask(a5),a0
  1243.     move.l    pr_ConsoleTask(a0),d0
  1244.     move.l    d0,packettask(a5)
  1245.     beq.s    .A
  1246.     bsr    GetDiskInfo
  1247.     moveq    #0,d0
  1248.     tst.l    sp_res1(a5)
  1249.     beq.s    .A
  1250.     move.l    id_VolumeNode(a5),d0    it is in here !
  1251. .A    rts
  1252.  
  1253. KillAppWin
  1254.     move.l    appwindow(a5),d2
  1255.     beq.s    .B
  1256.     bsr    OpenWBLib
  1257.     move.l    d2,a0
  1258.     jsr    _LVORemoveAppWindow(a6)
  1259. .B    move.l    appwinport(a5),d0
  1260.     beq.s    .A
  1261.     move.l    d0,a0
  1262.     move.l    4.w,a6
  1263.     jsr    _LVODeleteMsgPort(a6)
  1264. .A    move.l    dosbase(a5),a6
  1265.     rts
  1266.  
  1267.  
  1268. OutputCLInum        ;ENTRY: d1=0:start, d1=1:end
  1269.     btst    #FLdebug,Flags+3(a5)
  1270.     beq.s    .A
  1271.     lea    tempbuf(a5),a1
  1272.     bsr    InsertCLInum
  1273.     tst.l    d1
  1274.     beq.s    .B
  1275.     lea    end_tx(pc),a2
  1276. .C    move.b    (a2)+,(a1)+
  1277.     bne.s    .C
  1278.     subq.l    #1,a1
  1279. .B    move.b    #LF,(a1)+
  1280.     clr.b    (a1)
  1281.     lea    tempbuf(a5),a1
  1282.     bsr    pr_error
  1283. .A    rts
  1284.  
  1285. * PRINT DECIMAL print D0 as decimal
  1286. print10    movem.l    d0/a0-a1,-(sp)
  1287.     move.l    d0,-(sp)
  1288.     move.l    sp,a1
  1289.     lea    format(pc),a0
  1290.     bsr    new_print
  1291.     addq.l    #4,sp
  1292.     movem.l    (sp)+,d0/a0-a1
  1293.     rts
  1294.  
  1295. * PRINT HEXADECIMAL address in D0
  1296. printADR movem.l    d0/a0-a1,-(sp)
  1297.     move.l    d0,-(sp)
  1298.     move.l    sp,a1
  1299.     lea    formatADR(pc),a0
  1300.     bsr    new_print
  1301.     addq.l    #4,sp
  1302.     movem.l    (sp)+,d0/a0-a1
  1303.     rts
  1304.  
  1305. *PRINT STRING at a1    ;saves some of the important low registers
  1306. pr_space lea    space(pc),a1
  1307.     bra.s    pr_string
  1308. pr_tab    lea tab(pc),a1
  1309.     bra.s pr_string
  1310. pr_lf    lea lf(pc),a1
  1311. pr_string movem.l    d0-d3/a0-a3,-(sp)    print String in a1
  1312.     move.l    a1,d2
  1313.     moveq    #-1,d3
  1314. .A    addq.l    #1,d3
  1315.     tst.b    (a1)+
  1316.     bne.s    .A
  1317.     move.l    outhandle(a5),d1
  1318.     beq.s    .B
  1319.     jsr    _LVOWrite(a6)
  1320. .B    movem.l    (sp)+,d0-d3/a0-a3
  1321.     rts
  1322.  
  1323. *CHECK WHETHER A SCRIPT NAME WAS TYPED ON ENTRY TO ZSHELL
  1324. execscr    move.l    EntryA0(a5),d0
  1325.     move.l    d0,parm1(a5)
  1326.     beq.s    .C
  1327.     move.l    d0,a0
  1328.     tst.b    (a0)
  1329.     bne    xz2    ;NB this is OK, xz2 will pop the return addr 
  1330.             ;and jump to chorus
  1331.     rts
  1332. .C    moveq    #-1,d1        handle DEFAULT SCRIPT FILE s:zstart
  1333.     bsr    changeWindowPtr    disable volume requesters
  1334.     lea    defscript(pc),a2
  1335.     move.l    a2,d1
  1336.     moveq    #ACCESS_READ,d2
  1337.     jsr    _LVOLock(a6)
  1338.     moveq    #0,d1
  1339.     bsr    changeWindowPtr
  1340.     move.l    d0,d1    test lock
  1341.     beq.s    .B
  1342.     jsr    _LVOUnLock(a6)
  1343.     move.l    a2,a0
  1344.     bra    xz2
  1345. .B    rts
  1346.  
  1347. CheckForbid
  1348.     move.l    4.w,a0        Check for not closed
  1349.     moveq    #-1,d0
  1350.     cmp.b    294(a0),d0    Disables or
  1351.     bne.s    .A
  1352.     cmp.b    295(a0),d0    Forbids
  1353.     beq.s    .B
  1354. .A    move.b    d0,294(a0)    and avoids crashes !
  1355.     move.b    d0,295(a0)
  1356.     moveq    #22,d1
  1357.     bsr    GuruIt
  1358. .B    rts
  1359.  
  1360.     IFD    KILL
  1361. CleanUp    movem.l    d0-d7/a0-a6,-(sp)
  1362.     move.l    d1,a5
  1363.     bsr    DisplayBeep
  1364.     move.l    thistask(a5),a3
  1365.     clr.l    pr_ExitCode(a3)
  1366.     movem.l    (sp)+,d0-d7/a0-a6
  1367.     rts
  1368.     ENDC
  1369.  
  1370. **********************************************************
  1371. * Subroutine for complet, limiting chars:":","/","""," " *
  1372. cjk1    cmp.b    #":",-1(a1)
  1373.     beq.s    cjke
  1374.     cmp.b    #"/",-1(a1)
  1375.     beq.s    cjke
  1376. cjk2    cmp.b    #$22,-1(a1)
  1377.     beq.s    cjke
  1378.     cmp.b    #" ",-1(a1)
  1379. cjke    rts
  1380.  
  1381. FreeFNC    move.l    FNCbuffer(a5),d0
  1382.     beq.s    .A
  1383.     move.l    d0,a1
  1384.     move.l    FNCsize(a5),d0
  1385.     bsr    givemem
  1386. .A    clr.l    FNCbuffer(a5)
  1387. FlushFNC
  1388.     clr.l    FNCcycle(a5)
  1389.     clr.w    FNCfill(a5)
  1390.     clr.b    FNCbuffered(a5)
  1391.     rts
  1392.  
  1393. * Complete Filename in Shelline *
  1394. * INTERNAL: a2 points to part of filename, d6 length of part *
  1395. * ENTRY: d4: linmax , d5:linhere *
  1396. complet    tst.l    FNCcycle(a5)
  1397.     beq.s    .C
  1398.     moveq    #0,d2
  1399.     move.b    FNCchars(a5),d2
  1400.     bra.s    .G
  1401. .H    bsr    bs_str        delete some chars for cycling
  1402. .G    dbra    d2,.H
  1403. .C    clr.b    temp2buf(a5)
  1404.     lea    shelline(a5),a1
  1405.     move.l    a1,a0
  1406.     move.l    d5,d6
  1407.     beq.s    .B
  1408.     add.l    d5,a1
  1409.     bsr    cjk1
  1410.     beq.s    .B
  1411. .A    subq.l    #1,a1        look for begin of filename
  1412.     cmp.l    a1,a0
  1413.     beq.s    .B    
  1414.     bsr    cjk1
  1415.     bne.s    .A
  1416. .B    move.l    a1,a2        filename-pos. in a2
  1417.     sub.l    a0,a1
  1418.     sub.l    a1,d6        length in d6
  1419.     move.b    (a2),d3        save char
  1420.     clr.b    (a2)        null-end pathname
  1421.     move.l    a2,a1
  1422.     bra.s    .F
  1423. .D    subq.l    #1,a1        look for begin of path
  1424. .F    cmp.l    a1,a0
  1425.     beq.s    .E
  1426.     bsr    cjk2
  1427.     bne.s    .D
  1428. .E    move.l    a1,d1
  1429.     moveq    #-2,d2
  1430.     jsr    _LVOLock(a6)    lock path
  1431.     move.b    d3,(a2)        replace null-char by old one
  1432.     move.l    d0,d7        save lock
  1433.     beq    DisplayBeep
  1434.     bsr    fibexam2
  1435.     moveq    #0,d3
  1436.     tst.l    fib_DirEntryType(a5)
  1437.     bpl.s    cplbuf        if plus,is directory
  1438. cplunlk    move.l    d7,d1
  1439.     jsr    _LVOUnLock(a6)
  1440.     rts            an error occured
  1441.  
  1442. cplbuf    move.l    FNCbuffer(a5),d0
  1443.     bne.s    .A
  1444.     move.l    FNCsize(a5),d0
  1445.     moveq    #1,d1
  1446.     bsr    iwantmem
  1447.     beq.s    wdhcpl
  1448.     move.l    d0,FNCbuffer(a5)
  1449. .A    move.l    FNCcycle(a5),d1
  1450.     beq.s    .B
  1451.     move.l    d1,d0
  1452. .B    move.l    d0,a4
  1453.     move.b    #1,FNCbuffered(a5)
  1454.     move.l    d7,d0
  1455.     lsl.l    #2,d0
  1456.     move.l    d0,a1
  1457.     move.l    fl_Volume(a1),d0
  1458.     move.l    fl_Key(a1),d1
  1459.     lea    fib_Date(a5),a0
  1460.     move.l    (a0)+,d2
  1461.     add.l    (a0)+,d2
  1462.     add.l    (a0)+,d2
  1463.     tst.w    FNCfill(a5)
  1464.     beq.s    .C
  1465.     cmp.l    FNCvolume(a5),d0    check volume node
  1466.     bne.s    .C
  1467.     cmp.l    FNCkey(a5),d1        check disk block number
  1468.     bne.s    .C
  1469.     cmp.l    FNCdate(a5),d2        check date of last change
  1470.     beq.s    wdhcpl
  1471. .C    move.l    d0,FNCvolume(a5)
  1472.     move.l    d1,FNCkey(a5)
  1473.     move.l    d2,FNCdate(a5)
  1474.     move.l    FNCbuffer(a5),a4
  1475.     clr.l    FNCcycle(a5)
  1476.     clr.b    FNCbuffered(a5)
  1477.     clr.b    (a4)+
  1478.     move.l    FNCsize(a5),d0
  1479.     subq.l    #2,d0
  1480.     move.w    d0,FNCfill(a5)
  1481.  
  1482. wdhcpl    tst.b    FNCbuffered(a5)
  1483.     bne.s    .C
  1484.     bsr    fibexnx        not buffered: get next filename from dir
  1485.     tst.l    d0        next filename or dirname
  1486.     beq    endcpl
  1487.     lea    fib_FileName(a5),a0
  1488.     lea    FNCignore(a5),a1
  1489.     tst.b    (a1)
  1490.     beq.s    .A
  1491.     bsr    wildmatch2    wildcheck for names to ignore
  1492.     tst.b    d0
  1493.     beq.s    wdhcpl
  1494. .A    lea    fib_FileName(a5),a0
  1495.     lea    tempbuf(a5),a1    store filename in tempbuf
  1496.     move.l    a1,a3
  1497. .B    tst.w    FNCfill(a5)
  1498.     bne.s    .D
  1499.     move.b    (a0)+,(a1)+    buffer already full: only copy name
  1500.     bne.s    .B
  1501.     bra.s    .F
  1502. .D    subq.w    #1,FNCfill(a5)
  1503.     move.b    (a0),(a1)+    copy name
  1504.     move.b    (a0)+,(a4)+    store filename to buffer
  1505.     bne.s    .B
  1506. .F    moveq    #" ",d0        add a space at the end of files
  1507.     tst.l    fib_DirEntryType(a5)
  1508.     bmi.s    .G        if plus,is directory
  1509.     moveq    #"/",d0        add a / at the end of dirs
  1510. .G    move.b    d0,-1(a1)
  1511.     clr.b    (a1)        null-end
  1512.     tst.w    FNCfill(a5)
  1513.     beq.s    .E
  1514.     subq.w    #1,FNCfill(a5)    if buffer not full: do same with buffer
  1515.     move.b    d0,-1(a4)
  1516.     clr.b    (a4)+
  1517. .E    bra.s    wd2cpl
  1518.  
  1519. .C    tst.b    (a4)+        was buffered: skip to next name
  1520.     bne.s    .C
  1521.     tst.b    (a4)        test for end of buffer
  1522.     bne.s    .H
  1523.     tst.l    FNCcycle(a5)
  1524.     beq    endcpl
  1525.     move.l    FNCbuffer(a5),a4    end of buffer: set at begin
  1526.     addq.l    #1,a4        skip first null-byte
  1527. .H    move.l    a4,a3
  1528. wd2cpl    move.l    a3,a0
  1529.     move.l    a2,a1
  1530.     move.l    d6,d2
  1531.     bra.s    .I
  1532. .A    move.b    (a0)+,d0
  1533.     move.b    (a1)+,d1
  1534.     bsr    compD1D0locale        does it fit ?
  1535.     bne    wdhcpl
  1536. .I    dbra    d2,.A
  1537.     lea    temp2buf(a5),a0
  1538.     tst.l    d3
  1539.     bne.s    .B
  1540.     moveq    #-1,d0        ! first time: copy filename !
  1541. .C    addq.l    #1,d0
  1542.     move.b    (a3)+,(a0)+
  1543.     bne.s    .C
  1544.     moveq    #1,d3
  1545.     tst.l    FNCcycle(a5)
  1546.     beq    wdhcpl
  1547.     sub.l    d6,d0
  1548.     move.b    d0,FNCchars(a5)    chars more than given part of name
  1549.     move.l    a4,FNCcycle(a5)    position of next name to FNCcycle
  1550.     bra    endcpl
  1551.  
  1552. .B    btst    #FLmatch,Flags+3(a5)    ! next time !
  1553.     beq.s    .E
  1554.     tst.l    d3
  1555.     bmi.s    .E
  1556.     moveq    #-1,d3
  1557.     lea    hide_cursor(pc),a1
  1558.     bsr    pr_stringlf    print first time
  1559.     lea    temp2buf(a5),a1
  1560.     bsr    pr_string
  1561.     bsr    pr_space
  1562. .E    move.l    a3,a1
  1563. .G    move.b    (a0)+,d0
  1564.     move.b    (a1)+,d1
  1565.     bsr    compD1D0locale    next time: find longest common part
  1566.     bne.s    .D
  1567.     tst.b    -1(a0)
  1568.     beq.s    .D
  1569.     tst.b    -1(a1)
  1570.     bne.s    .G
  1571. .D    clr.b    -1(a0)
  1572.     btst    #FLmatch,Flags+3(a5)
  1573.     beq    wdhcpl
  1574.     lea    NewPrintBuffer(a5),a0
  1575.     move.l    a0,a1
  1576. .J    move.b    (a3)+,(a0)+
  1577.     bne.s    .J
  1578.     move.b    #" ",-1(a0)
  1579.     clr.b    (a0)
  1580.     bsr    pr_string    print other times
  1581.     bra    wdhcpl        repeat with all filenames
  1582.  
  1583. endcpl    tst.b    FNCbuffered(a5)
  1584.     bne.s    .A
  1585.     clr.b    (a4)        end buffer wth 0
  1586. .A    tst.l    d3
  1587.     bpl.s    .C        enable cycling if multiple matches found
  1588.     move.l    FNCbuffer(a5),FNCcycle(a5)
  1589.     clr.b    FNCchars(a5)
  1590. .C    move.l    d7,d1
  1591.     jsr    _LVOUnLock(a6)
  1592.     btst    #FLmatch,Flags+3(a5)
  1593.     beq    .B
  1594.     tst.l    d3        next time
  1595.     bpl.s    .B
  1596.     lea    show_cursor(pc),a1
  1597.     bsr    pr_stringlf
  1598. .B    lea    temp2buf(a5),a1
  1599.     move.l    d6,d2
  1600.     bra    print_def2
  1601.  
  1602. DisplayBeep
  1603.     move.l    intuibase(a5),a6
  1604.     suba.l    a0,a0
  1605.     jsr    _LVODisplayBeep(a6)
  1606.     move.l    dosbase(a5),a6
  1607.     rts
  1608.  
  1609.  
  1610. get_one_char
  1611.     bsr    clearArgs
  1612.     move.l    inhandle(a5),myArg1(a5)
  1613.     lea    tempbytes(a5),a0
  1614.     move.l    a0,myArg2(a5)
  1615.     moveq    #1,d0
  1616.     move.l    d0,myArg3(a5)
  1617.     move.l    thistask(a5),a0
  1618.     move.l    pr_ConsoleTask(a0),packettask(a5)
  1619.     moveq    #ACTION_READ,d0
  1620.     move.l    d0,packettype(A5)
  1621.     bsr    sendpacket2    read keyboard with packets
  1622.     moveq    #0,d3
  1623.     move.l    thistask(a5),a0
  1624.     move.b    pr_MsgPort+MP_SIGBIT(a0),d1
  1625.     bset    d1,d3        set wait bit for reading
  1626.     move.l    appwinport(a5),d2
  1627.     beq.s    .A
  1628.     move.l    d2,a0
  1629.     move.b    MP_SIGBIT(a0),d1
  1630.     bset    d1,d3        set wait bit for appwindow
  1631. .A    move.l    d3,d0
  1632.     jsr    _LVOWait(a6)    wait for anything
  1633.     tst.l    d2
  1634.     beq.s    .B
  1635.     move.l    d2,a0
  1636.     jsr    _LVOGetMsg(a6)    try to get appwinmsg
  1637.     tst.l    d0
  1638.     beq.s    .B
  1639.     move.l    d0,a2
  1640.     bsr    ProcessApp    look at it
  1641.     move.l    a2,a1
  1642.     jsr    _LVOReplyMsg(a6)
  1643.     move.l    dosbase(a5),a6
  1644.     lea    tempbuf(a5),a1
  1645.     move.l    d2,-(sp)
  1646.     bsr    print_def    write iconname to shelline
  1647.     move.l    (sp)+,d2
  1648.     move.l    intuibase(a5),a6
  1649.     move.l    windowptr(a5),d0
  1650.     bmi.s    .C
  1651.     beq.s    .C
  1652.     move.l    d0,a0
  1653.     jsr    _LVOActivateWindow(a6)
  1654. .C    move.l    4.w,a6
  1655.  
  1656. .B    move.l    thistask(a5),a0
  1657.     lea    pr_MsgPort(a0),a0
  1658.     jsr    _LVOGetMsg(a6)    try to get read-packet-reply
  1659.     move.l    d0,d1
  1660.     beq.s    .A
  1661.     move.l    dosbase(a5),a6
  1662.     lea    sp_node(a5),a0
  1663.     move.l    #212,d0
  1664.     cmp.l    d1,a0
  1665.     bne    pr_galactic    got wrong dospacket
  1666.     tst.l    sp_res1(a5)
  1667.     bmi.s    .D        error occured
  1668.     beq.s    .E
  1669.     move.b    tempbytes(a5),d6
  1670.     rts
  1671. .D    moveq    #20,d1
  1672.     bra.s    .F
  1673. .E    moveq    #21,d1
  1674. .F    bsr    GuruIt
  1675.     bra    cloga
  1676.  
  1677. saveundo
  1678.     lea    shelline(a5),a0
  1679.     lea    CLIbuf(a5),a1
  1680.     move.l    d4,d0
  1681.     bra.s    .B
  1682. .A    move.b    (a0)+,(a1)+
  1683. .B    dbra    d0,.A
  1684.     clr.b    (a1)
  1685.     rts
  1686.  
  1687. * A1 pts to past, d0=nost
  1688. gimme    lea    shelline(a5),a2
  1689.     move.l    d0,nost(a5)
  1690.     cmp.l    now(a5),d0
  1691.     bne.s    .C
  1692.     moveq    #-1,d4        reset linmax
  1693.     lea    CLIbuf(a5),a0
  1694. .D    addq.l    #1,d4
  1695.     move.b    (a0)+,(a2)+    copy undo to shelline
  1696.     bne.s    .D
  1697.     move.l    d4,d5        linmax=linhere
  1698.     bra    gimme3
  1699.  
  1700. .C    moveq    #0,d5        linhere = 0
  1701. .B    addq.l    #1,d0        copy to shelline
  1702.     and.l    #HISTORY_SIZE-1,d0
  1703.     cmp.b    #LF,0(a1,d0.l)
  1704.     beq.s    .A
  1705.     move.b    0(a1,d0.l),0(a2,d5.l)
  1706.     addq.l    #1,d5
  1707.     bra.s    .B
  1708. .A    move.l    d5,d4        linhere=linmax
  1709.  
  1710. gimme3    lea    shelline(a5),a2        Print input line newer
  1711.     lea    delete_line(pc),a1
  1712.     bsr    pr_string
  1713.     move.l    prompt_cr(a5),a1
  1714.     bsr    pr_string
  1715.     clr.b    0(a2,d4.l)    clear last
  1716.     move.l    a2,a1
  1717.     bsr    pr_string
  1718. restore_cursor
  1719.     move.l    d4,d0
  1720.     sub.l    d5,d0
  1721.     beq.s    .A
  1722.     bpl.s    cursor_left
  1723. .A    rts
  1724. cursor_left    ;move cursor d0 chars left
  1725.     lea    tempbuf(a5),a1
  1726.     move.l    a1,a0
  1727.     bra.s    .E
  1728. .F    move.w    #$9b<<8+"D",(a0)+    left cursor
  1729. .E    dbra    d0,.F        
  1730.     clr.b    (a0)
  1731.     bra    pr_string    restore cursorpos
  1732.  
  1733. cursor_right
  1734.     lea    tempbuf(a5),a1
  1735.     move.l    a1,a0
  1736.     bra.s    .A
  1737. .B    move.w    #$9b<<8+"C",(a0)+    right cursor
  1738. .A    dbra    d0,.B
  1739.     clr.b    (a0)
  1740.     bra    pr_string
  1741.  
  1742. ************************************************************************
  1743. * READ TEXT LINE from keyboard or script into buffer pointed to by a0,
  1744. * and clear last byte. NOTE A0 is essentially ignored, and shelline is the
  1745. * assumed address. Return with a0 same, and d0=length of text read
  1746. type_in    tst.b    scflag(a5)        ;check whether we're doing a script
  1747.     bne    scr_in
  1748. type_in2
  1749.     move.l    a0,-(sp)
  1750.     tst.l    ConsoleSwitch(a5)
  1751.     bne.s    .A
  1752.     move.l    a0,a2            use console in cooked mode
  1753. .C    move.l    a2,d2
  1754.     move.l    inhandle(a5),d1
  1755.     beq    cloga
  1756.     move.l    #SHELLINE_SIZE,d3
  1757.     jsr    _LVORead(a6)
  1758.     tst.l    d0
  1759.     bmi    cloga
  1760.     beq    cloga
  1761.     clr.b    0(a2,d0.l)
  1762.     cmp.b    #LF,-1(a2,d0.l)
  1763.     bne.s    .C
  1764.     cmp.b    #LF,(a2)
  1765.     bne.s    .B
  1766.     bsr    pr_prompt
  1767.     bra.s    .C
  1768. .B    move.l    (sp)+,a0
  1769.     rts
  1770.     
  1771. .A    clr.b    CLIbuf(a5)    (for undo)
  1772.     moveq    #0,d5        D5=linhere    use console in raw mode
  1773.     moveq    #0,d4        D4=linmax
  1774. next_ch    bsr    get_one_char
  1775.     cmp.b    #$9b,d6
  1776.     bne    not_csi
  1777.     clr.l    gather_ptr(a5)
  1778. fetch_csi    bsr    get_one_char
  1779.     lea    gather(a5),a0
  1780.     move.l    gather_ptr(a5),d0
  1781.     move.b    d6,0(a0,d0.l)        ;save byte from CSI sequence.
  1782.     addq.l    #1,gather_ptr(a5)
  1783.     moveq    #79,d1
  1784.     cmp.l    d1,d0
  1785.     blo.s    .A
  1786.     clr.l    gather_ptr(a5)
  1787. .A    cmp.b    #'@',d6
  1788.     blo.s    fetch_csi        ;keep gathering if char < @
  1789.     cmp.b    #'~',d6
  1790.     bhi.s    fetch_csi        ;keep gathering if char > ~
  1791.  
  1792.     cmp.b    #"|",d6        CHECK CLOSE GADGET
  1793.     bne.s    not_cloga
  1794. cloga2    btst    #FLappicon,Flags+3(a5)
  1795.     beq.s    cloga        exit immediately
  1796.     tst.b    openwin_flag(a5)
  1797.     beq.s    cloga
  1798.     bsr    WaitAppIcon
  1799.     addq.b    #1,noreview_flag(a5)
  1800.     bsr    raw_on
  1801. gimme3next
  1802.     bsr    gimme3
  1803.     bra.s    next_ch
  1804.  
  1805. cloga    move.l    dosbase(a5),a6    totally-exit-routine
  1806.     move.l    errorstack(a5),sp    ;kill return address on stack
  1807.     bsr    close_redirection
  1808.     bsr    raw_off
  1809.     bsr    kill_script
  1810.     moveq    #-1,d7
  1811.     rts
  1812.  
  1813. not_cloga
  1814.     cmp.b    #'C',d6        CHECK RIGHT ARROW    <CSI>C
  1815.     bne.s    not_right
  1816.     move.l    FNCcycle(a5),d0
  1817.     beq.s    .B
  1818.     cmp.l    FNCbuffer(a5),d0
  1819.     bne.s    .A
  1820. .B    cmp.l    d4,d5
  1821.     bhs.s    not_right
  1822.     addq.l    #1,d5
  1823.     moveq    #1,d0
  1824.     bsr    cursor_right
  1825. .A    clr.l    FNCcycle(a5)
  1826.     bra    next_ch
  1827.  
  1828. not_right
  1829.     clr.l    FNCcycle(a5)
  1830.     cmp.b    #'D',d6        CHECK LEFT ARROW    <CSI>D
  1831.     bne.s    not_left
  1832.     tst.l    d5
  1833.     beq.s    not_left
  1834.     subq.l    #1,d5
  1835.     moveq    #1,d0
  1836.     bsr    cursor_left
  1837.     bra    next_ch
  1838.     
  1839. not_left
  1840.     cmp.b    #'Z',d6        CHECK TAB & SHIFT    <CSI> Z
  1841.     bne.s    not_tab_left
  1842. v_buffer
  1843.     tst.l    ReviewSize(a5)
  1844.     beq    next_ch
  1845.     movem.l    d3-d7/a2-a4,-(sp)
  1846.     sub.l    a3,a3
  1847.     bsr    viewbuffer
  1848.     movem.l    (sp)+,d3-d7/a2-a4
  1849.     addq.b    #1,noreview_flag(a5)
  1850.     bra.w    gimme3next
  1851.  
  1852. not_tab_left    cmp.b    #'A',d6
  1853.     bne.s    not_sh_left
  1854.     cmp.b    #' ',gather(a5)    CHECK SHIFT LEFT ARROW    <CSI> A
  1855.     bne.s    not_sh_left
  1856.     move.l    d5,d0
  1857.     bsr    cursor_left
  1858.     moveq    #0,d5
  1859.     bra    next_ch
  1860.  
  1861. not_sh_left
  1862.     cmp.b    #'@',d6
  1863.     bne.s    not_sh_right
  1864.     cmp.b    #' ',gather(a5)    CHECK SHIFT RIGHT ARROW    <CSI> @
  1865.     bne.s    not_sh_right
  1866.     move.l    d4,d0
  1867.     sub.l    d5,d0
  1868.     bsr    cursor_right
  1869.     move.l    d4,d5
  1870.     bra    next_ch
  1871.  
  1872. not_sh_right
  1873.     cmp.b    #'A',d6        CHECK UP ARROW
  1874.     bne.s    not_up
  1875.     lea    past(a5),a1
  1876.     move.l    nost(a5),d0
  1877.     cmp.l    then(a5),d0
  1878.     beq.s    .B
  1879. .A    subq.l    #1,d0
  1880.     and.l    #HISTORY_SIZE-1,d0    wrap around
  1881.     cmp.b    #LF,0(a1,d0.l)
  1882.     bne.s    .A
  1883. .B    bsr    gimme
  1884.     bra    next_ch
  1885.  
  1886. not_up    cmp.b    #'B',d6        CHECK DOWN ARROW
  1887.     bne.s    not_down
  1888. up_bit    lea    past(a5),a1    called by shift down bit
  1889.     move.l    nost(a5),d0
  1890.     cmp.l    now(a5),d0
  1891.     beq.s    .B
  1892. .A    addq.l    #1,d0
  1893.     and.l    #HISTORY_SIZE-1,d0
  1894.     cmp.b    #LF,0(a1,d0.l)
  1895.     bne.s    .A
  1896. .B    bsr    gimme
  1897.     bra    next_ch
  1898.  
  1899. not_down    cmp.b    #'T',d6        CHECK SHIFT UP
  1900.     bne    not_sh_up
  1901.     lea    past(a5),a1
  1902.     tst.l    d5
  1903.     bne.s    search_his
  1904.     move.l    then(a5),nost(a5)    nost = then (the top)
  1905.     move.l    nost(a5),d0
  1906.     bsr    gimme
  1907.     bra    next_ch
  1908. search_his            ;search shelline in history    V2.0
  1909.     move.l    nost(a5),d0
  1910. .C    cmp.l    then(a5),d0
  1911.     bne.s    .A
  1912.     move.l    nost(a5),d0
  1913.     bra.s    end_seh
  1914. .A    subq.l    #1,d0
  1915.     and.l    #HISTORY_SIZE-1,d0
  1916.     cmp.b    #LF,0(a1,d0.l)
  1917.     bne.s    .A
  1918.  
  1919.     lea    shelline(a5),a0
  1920.     move.l    d5,d1
  1921.     subq.l    #1,d1
  1922.     move.l    d0,d2
  1923. .D    addq.l    #1,d2
  1924.     and.l    #HISTORY_SIZE-1,d2
  1925.     movem.l    d0/d1,-(sp)
  1926.     move.b    0(a1,d2.l),d0
  1927.     move.b    (a0),d1
  1928.     bsr    compD1D0locale
  1929.     movem.l    (sp)+,d0/d1
  1930.     bne.s    .C
  1931.     addq.l    #1,a0
  1932.     dbra    d1,.D
  1933. end_seh    move.l    d5,d2        save d5
  1934.     bsr    gimme
  1935.     move.l    d2,d5
  1936.     bsr    restore_cursor
  1937.     bra    next_ch
  1938.  
  1939.  
  1940. not_sh_up    cmp.b    #'S',d6        CHECK SHIFT DOWN
  1941.     bne.s    not_sh_down
  1942.     move.l    now(a5),nost(a5)    nost = now (the bottom)
  1943.     bra    up_bit
  1944.     
  1945. not_sh_down
  1946.     cmp.b    #'~',d6        CHECK FUNCTION KEYS AND HELP KEY
  1947.     bne    next_ch
  1948.     cmp.b    #'?',gather(a5)
  1949.     bne.s    process_the_func_key
  1950.     lea    help_ret(pc),a1
  1951.     bsr    print_def    will rip last address off stack
  1952. * never gets to this line
  1953. process_the_func_key
  1954.     bsr    translate_func_key
  1955.     bra    next_ch
  1956.         
  1957. * Was not a CSI code
  1958.  
  1959. *********************************************************************
  1960. not_csi    cmp.b    ctrl_codes+6(a5),d6        CHECK ESCAPE (ctrl+[)
  1961.     beq    cloga2        exit immediately
  1962.  
  1963. not_esc    cmp.b    ctrl_codes+4(a5),d6        CHECK TAB
  1964.     bne.s    not_ctrla
  1965.     move.l    FNCcycle(a5),d0
  1966.     movem.l    d0/d3/d6/d7/a3/a4,-(sp)
  1967.     bsr    complet        complete filename
  1968.     movem.l    (sp)+,d0/d3/d6/d7/a3/a4
  1969.     tst.l    d0
  1970.     bne.s    .A
  1971.     bsr    saveundo
  1972. .A    bra    next_ch
  1973.  
  1974. not_ctrla
  1975.     clr.l    FNCcycle(a5)
  1976.     cmp.b    ctrl_codes+7(a5),d6        CHECK CTRL T
  1977.     bne.s    not_tab_right
  1978.     moveq    #0,d0        one word forward
  1979. .A    cmp.l    d4,d5
  1980.     bhs.s    .B
  1981.     addq.l    #1,d5
  1982.     addq.l    #1,d0
  1983.     lea    shelline-1(a5),a0
  1984.     bsr    tab_check
  1985.     bne.s    .A
  1986. .B    bsr    cursor_right
  1987.     bra    next_ch
  1988.     
  1989. not_tab_right
  1990.     cmp.b    ctrl_codes+8(a5),d6        CHECK CTRL Y
  1991.     beq    v_buffer        same as shift&tab
  1992.  
  1993.     cmp.b    ctrl_codes+9(a5),d6        CHECK BACKSPACE (ctrl+H)
  1994.     bne.s    not_bs
  1995.     tst.l    d5
  1996.     beq.s    .A
  1997.     lea    backspace_it(pc),a1
  1998.     bsr    pr_string
  1999.     bsr    bs_str
  2000.     bsr    saveundo
  2001. .A    bra    next_ch
  2002.  
  2003. bs_str    subq.l    #1,d5
  2004. del_str    lea    shelline(a5),a0
  2005.     add.l    d5,a0
  2006.     lea    1(a0),a1
  2007.     move.l    d4,d0
  2008.     sub.l    d5,d0
  2009.     bra.s    .B
  2010. .A    move.b    (a1)+,(a0)+
  2011. .B    dbra    d0,.A
  2012.     subq.l    #1,d4
  2013.     rts
  2014.  
  2015. not_bs    cmp.b    #$7f,d6                CHECK DELETE
  2016.     bne.s    not_del
  2017.     cmp.l    d4,d5
  2018.     bhs.s    .A
  2019.     lea    delete_it(pc),a1
  2020.     bsr    pr_string
  2021.     bsr    del_str
  2022.     bsr    saveundo
  2023. .A    bra    next_ch
  2024.     
  2025. not_del    cmp.b    ctrl_codes+5(a5),d6        CHECK CTRL X
  2026.     bne.s    not_ctrlx
  2027.     bsr    saveundo
  2028.     moveq    #0,d5        delete shelline
  2029.     moveq    #0,d4
  2030.     bra    gimme3next
  2031.     
  2032. not_ctrlx
  2033.     cmp.b    ctrl_codes+3(a5),d6        CHECK CTRL E
  2034.     bne.s    not_ctrle
  2035. .A    cmp.l    d4,d5        delete to end of line
  2036.     bhs.s    .B
  2037.     lea    delete_it(pc),a1
  2038.     bsr    pr_string
  2039.     bsr    del_str
  2040.     bra.s    .A
  2041. .B    bsr    saveundo
  2042.     bra    next_ch
  2043.     
  2044. not_ctrle
  2045.     cmp.b    ctrl_codes+2(a5),d6        CHECK CTRL S
  2046.     bne.s    not_ctrls
  2047. .A    tst.l    d5        delete to start of line
  2048.     beq.s    .B
  2049.     lea    backspace_it(pc),a1
  2050.     bsr    pr_string
  2051.     bsr    bs_str
  2052.     bra.s    .A
  2053. .B    bsr    saveundo
  2054.     bra    next_ch
  2055.     
  2056. not_ctrls
  2057.     cmp.b    ctrl_codes+1(a5),d6        CHECK CTRL Q
  2058.     bne.s    not_ctrlw
  2059. .A    tst.l    d5        delete last word
  2060.     beq.s    .B
  2061.     lea    backspace_it(pc),a1
  2062.     bsr    pr_string
  2063.     bsr    bs_str
  2064.     lea    shelline-1(a5),a0
  2065.     bsr    tab_check
  2066.     bne.s    .A
  2067.     bsr    saveundo
  2068. .B    bra    next_ch
  2069.  
  2070. not_ctrlw
  2071.     cmp.b    ctrl_codes+0(a5),d6        CHECK CTRL W
  2072.     bne.s    not_ctrlq
  2073. .A    cmp.l    d4,d5        delete next word
  2074.     bhs.s    .B
  2075.     lea    delete_it(pc),a1
  2076.     bsr    pr_string
  2077.     bsr    del_str
  2078.     lea    shelline+0(a5),a0
  2079.     bsr    tab_check
  2080.     bne.s    .A
  2081.     bsr    saveundo
  2082. .B    bra    next_ch
  2083.  
  2084. not_ctrlq
  2085.     cmp.b    ctrl_codes+10(a5),d6        CHECK CTRL J
  2086.     bne.s    not_ctrlj
  2087.     bsr    do_cr2        push to history
  2088.     move.l    errorstack(a5),sp
  2089.     bra    chorus
  2090.  
  2091. not_ctrlj
  2092.     cmp.b    ctrl_codes+12(a5),d6        CHECK CTRL L
  2093.     bne.s    not_ctrll
  2094.     lea    clrtx(pc),a1
  2095.     bsr    pr_string    clear window
  2096.     bra    gimme3next
  2097.  
  2098. not_ctrll
  2099.     cmp.b    ctrl_codes+13(a5),d6        CHECK CTRL R
  2100.     bne.s    not_ctrlr
  2101.     moveq    #0,d0        one word back
  2102. tab_left tst.l    d5
  2103.     beq.s    .B
  2104.     subq.l    #1,d5
  2105.     addq.l    #1,d0
  2106.     lea    shelline-1(a5),a0
  2107.     bsr    tab_check
  2108.     bne.s    tab_left
  2109. .B    bsr    cursor_left
  2110.     bra    next_ch
  2111.  
  2112. tab_check cmp.b    #' ',0(a0,d5.w) words are separated by / . : or space
  2113.     beq.s    .A
  2114.     cmp.b    #':',0(a0,d5.w)
  2115.     beq.s    .A
  2116.     cmp.b    #'.',0(a0,d5.w)
  2117.     beq.s    .A
  2118.     cmp.b    #'/',0(a0,d5.w)
  2119. .A    rts
  2120.  
  2121. not_ctrlr
  2122.     cmp.b    ctrl_codes+14(a5),d6        CHECK CTRL V
  2123.     bne.s    not_ctrlv
  2124.     movem.l    d3-d7/a2-a4,-(sp)
  2125.     lea    past(a5),a2
  2126.     move.l    now(a5),d3
  2127.     move.l    #HISTORY_SIZE,d2
  2128.     sub.l    a3,a3
  2129.     bsr    viewhist    view history buffer
  2130.     movem.l    (sp)+,d3-d7/a2-a4
  2131.     addq.b    #1,noreview_flag(a5)
  2132.     bra    gimme3next
  2133.  
  2134. not_ctrlv
  2135.     cmp.b    ctrl_codes+15(a5),d6        CHECK CTRL F
  2136.     bne.s    not_ctrlf
  2137.     move.l    4.w,a6        Display Filerequester
  2138.     lea    aslname(pc),a1
  2139.     jsr    _LVOOldOpenLibrary(a6)
  2140.     tst.l    d0
  2141.     beq.s    .A
  2142.     move.l    d0,a6
  2143.     jsr    _LVOAllocFileRequest(a6)
  2144.     move.l    d0,d2
  2145.     beq.s    .B
  2146.     move.l    d2,a0
  2147.     jsr    _LVORequestFile(a6)
  2148.     tst.l    d0
  2149.     beq.s    .C
  2150.     move.l    d2,a0
  2151.     move.l    rf_File(a0),a1
  2152.     move.l    rf_Dir(a0),a0
  2153.     lea    tempbuf(a5),a2
  2154.     bsr    addpath
  2155.     move.l    a2,a1
  2156.     bsr    print_def
  2157. .C    move.l    d2,a0
  2158.     jsr    _LVOFreeFileRequest(a6)
  2159. .B    move.l    a6,a1
  2160.     move.l    4.w,a6
  2161.     jsr    _LVOCloseLibrary(a6)
  2162. .A    move.l    dosbase(a5),a6
  2163.     bra    gimme3next
  2164.  
  2165. not_ctrlf
  2166.     cmp.b    ctrl_codes+16(a5),d6        CHECK CTRL P
  2167.     bne.s    not_ctrlp
  2168.     bsr    FlushFNC    flush FNC buffer
  2169.     bra    next_ch
  2170.  
  2171. not_ctrlp
  2172.     cmp.b    ctrl_codes+11(a5),d6        CHECK CTRL M
  2173.     beq.s    do_cr
  2174.     cmp.b    #13,d6                CHECK CR
  2175.     beq    do_cr
  2176. no_cr    cmp.b    #" ",d6    
  2177.     blo.s    .A
  2178.     bsr    ins_char
  2179.     bsr    saveundo
  2180. .A    bra    next_ch
  2181.  
  2182.  
  2183. ******************************************************************
  2184. do_cr    move.l    (sp)+,a2
  2185. do_cr2    lea    return_it(pc),a1
  2186.     bsr    pr_string
  2187.     lea    shelline(a5),a4
  2188.     move.b    #LF,0(a4,d4.w)    HACK JOB    (MUST END IN LF 0)
  2189.     clr.b    1(a4,d4.w)    FOR ALIAS STUFF
  2190.     tst.l    d4        CHECK IF NOTHING TYPED
  2191.     bne.s    history_it
  2192.     bsr    pr_prompt        IF JUST HIT RETURN, THEN START AGAIN
  2193.     move.l    a2,a0
  2194.     bra    type_in2
  2195. history_it
  2196.     lea    past(a5),a1    CHECK IF LAST ENTRY IS SAME AS CURRENT
  2197.     move.l    now(a5),d0
  2198.     cmp.l    then(a5),d0
  2199.     beq.s    .B
  2200.     move.l    d0,nost(a5)
  2201. .A    subq.l    #1,d0        FIND LAST
  2202.     and.l    #HISTORY_SIZE-1,d0    WRAP AROUND
  2203.     cmp.b    #LF,0(a1,d0.l)
  2204.     bne.s    .A
  2205.     lea    (a4),a0
  2206.     bra.s    .C
  2207. .D    cmp.b    #LF,d1        COMPARE LAST TO SHELLINE
  2208.     beq    finland
  2209. .C    addq.l    #1,d0
  2210.     and.l    #HISTORY_SIZE-1,d0
  2211.     move.b    (a0)+,d1
  2212.     cmp.b    0(a1,d0.l),d1
  2213.     beq.s    .D
  2214.  
  2215. .B    move.l    a4,a3    lin    COPY LINE TO HISTORY  BUFFER
  2216.     move.l    now(a5),d3    pts to the last LF
  2217.  
  2218. .E    addq.l    #1,d3
  2219.     and.l    #HISTORY_SIZE-1,d3        WRAP AROUND
  2220.     move.b    (a3)+,d0
  2221.     move.b    d0,0(a1,d3.l)
  2222.     cmp.b    #LF,d0
  2223.     bne.s    .E
  2224. ;dumped_hist
  2225.     move.l    d3,nost(a5)    nost = now
  2226.     move.l    d3,now(a5)
  2227.     move.l    then(a5),d1
  2228.     cmp.b    #LF,0(a1,d1.l)
  2229.     bne.s    .G    BRANCH IF WRAPPED AROUND
  2230.     cmp.l    d3,d1
  2231.     bne.s    finland    BRANCH IF THEN = (10) & THEN <> NOW
  2232. .G    
  2233. *    move.l    d3,then(a5)    then=now
  2234. .H    addq.l    #1,d3    SEARCH FOR NEXT LF (NEW TOP OF HISTORY)
  2235.     and.l    #HISTORY_SIZE-1,d3        WRAP AROUND
  2236.     move.b    0(a1,d3.l),d0
  2237.     cmp.b    #LF,d0
  2238.     bne.s    .H        ***
  2239.     move.l    d3,then(a5) SET NEW THEN (TOP OF HISTORY)
  2240.  
  2241. ******* 
  2242. finland    tst.b    scflag(a5)
  2243.     bne.s    .D
  2244.     lea    prompt_string(a5),a1    write to review-buffer
  2245.     move.l    a1,d2
  2246.     moveq    #-1,d3
  2247. .E    addq.l    #1,d3
  2248.     tst.b    (a1)+
  2249.     bne.s    .E
  2250.     bsr    toreview
  2251.     move.l    a2,d2
  2252.     move.l    d4,d3
  2253.     addq.l    #1,d3
  2254.     bsr    toreview
  2255. .D    move.l    a2,a0
  2256.     move.l    d4,d0
  2257.     rts
  2258.  
  2259. * insert a char in the shelline
  2260. ins_char cmp.w    #SHELLINE_SIZE-2,d4    make sure line is not too long
  2261.     bhs    DisplayBeep
  2262.     lea    tempbuf(a5),a1
  2263.     move.w    #$9b<<8+"@",(a1)
  2264.     clr.b    3(a1)
  2265.     move.b    d6,2(a1)    shove printable char after insert seq
  2266.     bsr    pr_string        insert space for char
  2267.     lea    shelline(a5),a1    ethel
  2268.     lea    1(a1,d4.w),a0    linmax
  2269.     lea    1(a0),a2        A2=linmax+1
  2270.     lea    0(a1,d5.w),a1    linhere
  2271. .A    move.b    -(a0),-(a2)    insert char into shelline
  2272.     cmp.l    a0,a1
  2273.     bne.s    .A
  2274.     lea    shelline(a5),a4
  2275.     move.b    d6,0(a4,d5.w)
  2276.     addq.l    #1,d5
  2277.     addq.l    #1,d4
  2278. .B    rts
  2279.  
  2280. * TRANSLATE FUNC CODE TO F1,F2 ETC AND SET UP POINTERS
  2281. translate_func_key
  2282.     lea    gather(a5),a0
  2283.     move.l    gather_ptr(a5),d0
  2284.     cmp.b    #3,d0        CHECK IF TWO CODES EG '12'
  2285.     beq    process_shift_func
  2286. unshifted_func_key
  2287.     cmp.b    #2,d0
  2288.     bne    translate_func_fail
  2289.     move.b    (A0),d0
  2290.     moveq    #'f',d1
  2291. act_sh    bsr    convert_to_set_name
  2292.     bsr    search_sets    returns D0 pointer to set
  2293. *d0=set ptr
  2294. *print_func_defn
  2295.     tst.l    d0
  2296.     beq.s    do_not_print_func
  2297.     move.l    d0,a1
  2298.     lea    set_defn(a1),a1
  2299. print_def    ;insert string in a1 into shelline
  2300.     moveq    #0,d2
  2301. print_def2    ;for FNC, d2=number of chars before
  2302.     moveq    #-1,d1
  2303. .G    addq.l    #1,d1        D1=length
  2304.     tst.b    (a1)+
  2305.     bne.s    .G
  2306.     sub.l    d2,d1
  2307.     bmi    DisplayBeep
  2308.     subq.l    #1,a1        for later
  2309.     move.l    d4,d0
  2310.     add.l    d1,d0
  2311.     cmp.w    #SHELLINE_SIZE-2,d0    make sure line is not too long
  2312.     bhs    DisplayBeep
  2313.     movem.l    a2-a3,-(sp)
  2314.     lea    shelline(a5),a0    ethel
  2315.     lea    1(a0,d4.w),a3    A3=linmax
  2316.     move.l    a3,a2
  2317.     add.l    d1,a2        A2=linmax+length
  2318.     lea    0(a0,d5.w),a0    linhere
  2319. .A    move.b    -(a3),-(a2)    insert chars into shelline
  2320.     cmp.l    a3,a0
  2321.     bne.s    .A
  2322.     move.l    d1,d0
  2323.     add.l    d2,d0
  2324.     bra.s    .C
  2325. .D    move.b    -(a1),-(a2)    copy found filename
  2326. .C    dbra    d0,.D
  2327.     movem.l    (sp)+,a2-a3
  2328.     add.l    d1,d5
  2329.     add.l    d1,d4
  2330.  
  2331.     lea    shelline(a5),a0
  2332.     cmp.b    #'M',-1(a0,d5.l)    check for auto return ^M
  2333.     bne.s    .F
  2334.     cmp.b    #'^',-2(a0,d5.l)
  2335.     bne.s    .F
  2336.     subq.l    #2,d5
  2337.     move.l    d5,d4
  2338.     bsr    gimme3        print it
  2339.     addq.l    #4,sp        get rid of last return address
  2340.     bra    do_cr        do a carriage return
  2341. .F    bsr    gimme3        print shelline
  2342. do_not_print_func
  2343.     rts
  2344.  
  2345. process_shift_func
  2346.     move.b    1(A0),d0
  2347.     moveq    #'F',d1
  2348.     bra    act_sh
  2349. translate_func_fail
  2350.     rts
  2351.  
  2352.  
  2353. convert_to_set_name
  2354.     lea    temp2buf(a5),a1
  2355.     move.b    d1,(a1)+
  2356.     addq.b    #1,d0
  2357.     move.b    d0,(a1)+
  2358.     cmp.b    #':',d0
  2359.     bne    not_func10
  2360.     move.b    #'1',-1(a1)
  2361.     move.b    #'0',(a1)+
  2362. not_func10
  2363.     clr.b    (a1)
  2364.     rts
  2365.  
  2366. search_sets
  2367. * uses temp2buf, EXIT: D0 ptr to the associated set. D1 pts to prior set
  2368. * RETURN D0=0 IF NOT FOUND.
  2369.     movem.l    d2-d4/a1-a2,-(sp)
  2370.     lea    temp2buf(a5),a1
  2371.     move.l    a1,d2
  2372.     lea    first_set_defn(a5),a2
  2373.     move.l    a2,d4        NOTE PRIOR SET 
  2374.     move.l    (a2),d3
  2375. search_next_set
  2376.     beq    .B
  2377.     move.l    d3,a2
  2378.     lea    set_name(a2),a2    A2=current set name
  2379.     move.l    d2,a1        A1=name to match
  2380.     bra.s    .C
  2381. .A    tst.b    d0
  2382.     beq.s    .B
  2383. .C    move.b    (a1)+,d0
  2384.     move.b    (a2)+,d1
  2385.     bsr    compD1D0locale
  2386.     beq.s    .A
  2387.  
  2388.     move.l    d3,a2
  2389.     move.l    d3,d4
  2390.     move.l    (a2),d3
  2391.     bra    search_next_set
  2392. .B    move.l    d3,d0
  2393.     move.l    d4,d1
  2394.     
  2395.     movem.l    (sp)+,d2-d4/a1-a2
  2396.     rts
  2397.  
  2398.  
  2399. * DO SCRIPT FILE STUFF   ENTRY A0 -> input line
  2400. scr_in    movem.l    a0-a1/a6,-(sp)
  2401.     clr.b    break_flag(a5)
  2402.     move.l    4.w,a6
  2403.     moveq    #0,d0
  2404.     moveq    #0,d1
  2405.     bset    #SIGBREAKB_CTRL_D,d1
  2406.     jsr    _LVOSetSignal(a6)
  2407.     movem.l    (sp)+,a0-a1/a6
  2408.     btst    #SIGBREAKB_CTRL_D,d0    ;checks if CTRL_D pressed
  2409.     beq.s    .B
  2410.     move.l    #304,d0
  2411.     bsr    pr_DOSerr
  2412.     move.b    #1,break_flag(a5)
  2413.     bra.s    terminate_script
  2414. .B    move.l    scsize(a5),d1    ;read a line from the script file
  2415.     add.l    scaddr(a5),d1
  2416.     sub.l    scptr(a5),d1
  2417.     beq.s    terminate_script
  2418.     bpl.s    scr_in2
  2419. terminate_script
  2420.     bsr    kill_script
  2421.     move.l    errorstack(a5),sp
  2422.     bra    chorus
  2423.  
  2424. scr_in2    move.l    a0,a2
  2425.     moveq    #0,d0
  2426.     move.l    scptr(a5),a1
  2427.     cmp.b    #LF,(a1)
  2428.     beq.s    .B
  2429. .A    move.b    (a1)+,(a2)+
  2430.     addq.l    #1,d0
  2431.     subq.l    #1,d1
  2432.     bne.s    .D
  2433.     move.b    #LF,(a2)+
  2434.     bra.s    .E
  2435. .D    cmp.b    #LF,(a1)
  2436.     bne.s    .A
  2437. .B    move.b    (a1)+,(a2)+    LF
  2438. .E    clr.b    (a2)        0
  2439.     move.l    a1,scptr(a5)
  2440.     btst    #FLdebug,Flags+3(a5)
  2441.     beq.s    .C
  2442.     clr.b    noreview_flag
  2443.     bsr    pr_prompt
  2444.     move.l    a0,a1
  2445.     bsr    pr_error
  2446. .C    rts
  2447.  
  2448. kill_script
  2449.     move.l    a0,-(sp)
  2450.     tst.b    scflag(a5)
  2451.     beq.s    .A
  2452.     move.l    scaddr(a5),a1
  2453.     move.l    scsize(a5),d0
  2454.     bsr    givemem
  2455. .A    clr.b    scflag(a5)    clean up if no more lines left
  2456.     clr.b    if_flag(a5)    Make sure if structure ends
  2457.     clr.b    goto_flag(a5)    Make sure goto is terminated
  2458.     clr.l    mult_comm_ptr(a5)    break multiple commands
  2459.     move.l    (sp)+,a0
  2460.     rts
  2461.  
  2462. ** SAME AS compare_strings EXCEPT
  2463. ** ALLOWS FOR A1 ENDING IN LF
  2464. lf_compare_strings
  2465.     movem.l    d0-d1/a0-a1,-(sp)
  2466.     bra.s    .A
  2467. .B    tst.b    d0
  2468.     beq.s    .C    RETURN EQ
  2469. .A    move.b    (a0)+,d0
  2470.     move.b    (a1)+,d1
  2471.     bsr    compD1D0nocase
  2472.     beq.s    .B    return NE
  2473.     tst.b    d0
  2474.     bne.s    .C
  2475.     cmp.b    #LF,d1
  2476. .C    movem.l    (sp)+,d0-d1/a0-a1
  2477.     rts
  2478.  
  2479.     
  2480. ** CASE INDEPENDENT STRING COMPARE. COMPARES (A0) TO (A1)
  2481. ** RETURN EQ IF SAME
  2482. compare_strings
  2483.     movem.l    d0-d1/a0-a1,-(sp)
  2484.     bra.s    .A
  2485. .B    tst.b    d0
  2486.     beq.s    .C    RETURN EQ
  2487. .A    move.b    (a0)+,d0
  2488.     move.b    (a1)+,d1
  2489.     bsr    compD1D0nocase
  2490.     beq.s    .B    return NE
  2491. .C    movem.l    (sp)+,d0-d1/a0-a1
  2492.     rts
  2493.  
  2494.     
  2495. * COPY STRING :copys null ending string from A0 to A1, Return with D0=length+1
  2496. cp_string    movem.l a0-a1,-(sp)
  2497.     moveq #0,d0
  2498. cp_str1    addq.l #1,d0
  2499.     move.b (a0)+,(a1)+
  2500.     bne.s cp_str1
  2501.     movem.l (sp)+,a0-a1
  2502.     rts
  2503.  
  2504. *Get line of text and seperate into up to 25 parameters    
  2505. get_line    addq.l    #1,count_line(a5)
  2506.     lea    ZShellName(pc),a0
  2507.     move.l    a0,parm1(a5)
  2508.     lea    shelline(a5),a0
  2509.     tst.l    mult_comm_ptr(a5) SKIP PROMPT IF SCRIPT OR MULT COMMANDS
  2510.     bne.s    .A
  2511.     tst.b    scflag(a5)
  2512.     bne.s    .B
  2513.     cmp.b    #2,WBflag(a5)
  2514.     bhs    endbground
  2515.     addq.b    #1,noreview_flag(a5)
  2516.     bsr    pr_prompt
  2517. .B    bsr    type_in    NOTE HISTORY STUFF ASSUMES SHELLINE HOLDS THE LINE
  2518.     clr.b    noreview_flag(a5)
  2519.     cmp.b    #';',(a0)        ;is 1st character a ';'
  2520.     beq.s    .C
  2521.     cmp.b    #'*',(a0)
  2522.     beq.s    .C
  2523.     cmp.b    #'#',(a0)
  2524.     bne.s    .A
  2525. .C    addq.l    #4,sp        ;kill return address
  2526.     bra    chorus        ;do next line if comment
  2527. .A    bsr    handle_mult_comms    MAYBE ALTER A0
  2528.     bsr    handle_command_alias
  2529.     bsr    handle_redirection
  2530.     bsr    handle_real_pipes
  2531.     btst    #FLdebug,Flags+3(a5)
  2532.     beq.s    gl16
  2533.     tst.b    scflag(a5)
  2534.     bne.s    gl16
  2535.     move.l    thistask(a5),a1
  2536.     move.l    pr_TaskNum(a1),d0
  2537.     lea    tempbuf(a5),a1
  2538.     bsr    qpr10        get CLI number
  2539.     move.l    #"-> "<<8,(a1)+
  2540.     subq.l    #6,a1
  2541.     bsr    pr_error
  2542.     move.l    a0,a1
  2543.     bsr    pr_error
  2544. gl16    move.l    a0,-(sp)    clear parms
  2545.     lea    parm1(a5),a0
  2546.     lea    endofparms(a5),a1
  2547. .A    clr.l    (a0)+
  2548.     cmp.l    a0,a1
  2549.     bne.s    .A
  2550.     move.l    (sp)+,a0
  2551.     lea    parm1(a5),a2 do 1st parm seperate to establish CLI residue
  2552.     bsr    get_parm
  2553.     move.l    a0,d7
  2554.     tst.l    d2
  2555.     beq    gl3            if no parms at all
  2556.     tst.b    goto_flag(a5)    CHECK IF IN GOTO SEARCH MODE
  2557.     beq.s    test_ifs
  2558.     move.l    a0,-(sp)
  2559.     lea    labeltx(pc),a0
  2560.     bsr    lf_compare_strings
  2561.     bne    skipline
  2562.     move.l    (sp)+,a0
  2563.  
  2564. * Script-IF handling
  2565. test_ifs    tst.b    if_flag(a5)    0 if if encountered earlier
  2566.     beq.s    no_ifs
  2567.     tst.b    if_condition(a5)    0 if condition TRUE
  2568.     beq    no_ifs
  2569. if_false    move.l    a0,-(sp)        push ptr to next
  2570.     lea    elsetx(pc),a0
  2571.     bsr    lf_compare_strings
  2572.     bne.s    try_endif
  2573.     not.b    if_condition(a5)    flip condition flag
  2574. skipline    movem.l    (sp)+,d0-d1    get rid of last plus return address
  2575.     bra    chorus
  2576. try_endif    lea    endiftx(pc),a0
  2577.     bsr    lf_compare_strings
  2578.     bne.s    skipline
  2579.     clr.b    if_flag(a5)
  2580.     bra.s    skipline
  2581.  
  2582. no_ifs    move.l    a1,(a2)+    save address of parm1
  2583.  
  2584.     lea    CLIbuf(a5),a1
  2585. .C    move.b    (a0)+,d0    skip all preceding spaces
  2586.     cmp.b    #LF,d0
  2587.     beq    .D
  2588.     cmp.b    #" ",d0
  2589.     beq.s    .C
  2590. .B    move.b    d0,(a1)+
  2591.     move.b    (a0)+,d0    copy sudoCLIresidue out
  2592.     cmp.b    #LF,d0        only look for LF end
  2593.     bne.s    .B
  2594. .E    move.b    -(a1),d0    skip all ending spaces
  2595.     cmp.b    #" ",d0
  2596.     beq.s    .E
  2597.     addq.l    #1,a1
  2598. .D    clr.b    (a1)        null end the copy
  2599.     move.l    d7,a0
  2600.     lea    endofparms(a5),a4    establish end of parms block
  2601. gl4    bsr    get_parm        
  2602.     tst.l    d2
  2603.     beq.s    gl3
  2604.     move.l    a1,(a2)+
  2605.     cmp.l    a2,a4        get out if more than 25 parms
  2606.     bne.s    gl4
  2607.     clr.b    (a0)        make sure parm ends in 0
  2608. gl3    rts
  2609.  
  2610. endifz    clr.b    if_flag(a5)
  2611.     moveq    #RETURN_OK,d0
  2612.     rts
  2613. elsez    not.b    if_condition(a5)
  2614.     moveq    #RETURN_OK,d0
  2615.     rts
  2616.  
  2617. *************************
  2618. *        SKIP         *
  2619. *************************
  2620.  
  2621. skipz    move.l    parm2(a5),d1
  2622.     beq    too_less_args
  2623. test_gs    tst.b    scflag(a5)    CAN ONLY GOTO FROM WITHIN SCRIPT
  2624.     bne.s    .A
  2625.     moveq    #RETURN_ERROR,d0
  2626.     rts
  2627. .A    move.l    d1,a0
  2628.     lea    dest_label(a5),a1
  2629. .B    move.b    (a0)+,(a1)+
  2630.     bne.s    .B
  2631.     move.l    scaddr(a5),scptr(a5)  RESET TO START OF SCRIPT
  2632.     move.b    #$ff,goto_flag(a5)
  2633.     clr.b    if_flag(a5)    MAKE SURE IF IS TERMINATED
  2634.     moveq    #RETURN_OK,d0
  2635.     rts
  2636.  
  2637. *************************
  2638. *    LABEL        *     DOES NOTHING IF NOT IN GOTO SEARCH MODE
  2639. *************************
  2640. labelz    tst.b    goto_flag(a5)
  2641.     bne.s    .A
  2642. .B    moveq    #RETURN_OK,D0
  2643.     RTS
  2644. .A    move.l    parm2(a5),d0
  2645.     beq.s    .B
  2646.     move.l    d0,a0
  2647.     lea    dest_label(a5),a1
  2648.     bsr    compare_strings
  2649.     bne    .B
  2650.     clr.b    goto_flag(a5)
  2651.     bra.s    .B
  2652.     
  2653.     
  2654. *ENTRY A0=shelline    ONLY HANDLES ALIASES OF FIRST KEYWORD.
  2655. handle_command_alias
  2656.     movem.l    d0-d2/a1-a4,-(sp)
  2657.     cmp.b    #LF,(a0)
  2658.     beq    hca_nothing_typed
  2659.     move.l    a0,a1
  2660. .A    cmp.b    #" ",(a1)+
  2661.     beq.s    .A
  2662.     subq.l    #1,a1
  2663.     lea    tempbuf(a5),a3
  2664.     move.b    #LF,(a3)
  2665.     clr.b    1(a3)    must be null end string
  2666.     lea    temp2buf(a5),a2    COPY PARM AT A0 TO SEARCH STR
  2667. .B    move.b    (a1)+,(a2)+
  2668.     cmp.b    #LF,(a1)
  2669.     beq.s    .D        hca_one_parm
  2670.     cmp.b    #" ",(a1)
  2671.     bne.s    .B
  2672. .D    move.b    (a1)+,(a3)+    COPY FROM SPACE ONWARDS to tempbuf
  2673.     bne.s    .D    WHOLE LINE ENDS IN NULL.
  2674. hca_one_parm
  2675.     clr.b    (a2)    null end search string
  2676.  
  2677. hca_find_it
  2678.     move.l    a0,-(sp)
  2679.     bsr    search_sets
  2680.     move.l    (sp)+,a0
  2681.     tst.l    d0
  2682.     beq    hca_nothing_typed
  2683.     move.l    d0,a2
  2684.  
  2685.     lea    set_defn(a2),a2    A2=set defn
  2686.     lea    tempbuf(a5),a3    A3=line after alias
  2687.     move.l    a0,a1        A1=shelline ptr
  2688.     moveq    #7,d0
  2689. .F    clr.l    -(sp)        push down eight times 0=no entry.
  2690.     dbra    d0,.F
  2691. .E    move.b    (a2)+,d0        handle %1...$1
  2692.     beq    not_much_of_an_alias
  2693.     cmp.b    #$20,d0        skip spaces
  2694.     beq.s    .E
  2695.     cmp.b    #'%',d0
  2696.     bne.s    no_extra_parms
  2697.     move.b    (a2)+,d0
  2698.     and.w    #$0007,d0        only allow %0 --> %7
  2699. .A    move.b    (a3)+,d1        find where the next param starts
  2700.     cmp.b    #LF,d1
  2701.     beq.s    .C        if no param then pt A3 to lf again
  2702.     cmp.b    #$20,d1
  2703.     beq.s    .A
  2704. .D    lsl.w    #2,d0        x 4
  2705.     move.l    a3,0(sp,d0.w)
  2706.     subq.l    #1,0(sp,d0.w)    put address of param on stack
  2707. .B    move.b    (a3)+,d1        get a3 to pt to next space
  2708.     cmp.b    #LF,d1
  2709.     beq    .C
  2710.     cmp.b    #$20,d1
  2711.     bne.s    .B
  2712. .C    lea    -1(a3),a3        a3 ts to space
  2713.     bra.s    .E        do for more params
  2714. get_next_character
  2715.     move.b    (a2)+,d0
  2716. no_extra_parms
  2717.     cmp.b    #'$',d0
  2718.     bne.s    .A
  2719.     move.b    (a2)+,d0        grab number after $
  2720.     beq.s    not_much_of_an_alias
  2721.     and.w    #$0007,d0
  2722.     lsl.w    #2,d0        x 4
  2723.     move.l    0(sp,d0.w),d1
  2724.     beq.s    get_next_character
  2725.     move.l    d1,a4
  2726. .B    move.b    (a4)+,(a1)+    copy param N
  2727.     cmp.b    #LF,(a4)
  2728.     beq.s    .C
  2729.     cmp.b    #$20,(a4)
  2730.     bne.s    .B
  2731. .C    bra.s    get_next_character
  2732. .A    move.b    d0,(a1)+        copy DEFN -> SHELLINE
  2733.     tst.b    d0
  2734.     bne.s    get_next_character
  2735.  
  2736.     lea    -1(a1),a1
  2737. not_much_of_an_alias
  2738.     lea    32(sp),sp        ** NOTE STACK CHANGE
  2739. .D    move.b    (a3)+,(a1)+    copy tempbuf onto end
  2740.     bne.s    .D
  2741.     moveq    #100,d0
  2742.     bsr    stacktest
  2743.     bne    redirtw
  2744.     clr.l    mult_comm_ptr(a5)
  2745.     bsr    handle_mult_comms
  2746.     bsr    handle_command_alias
  2747.     clr.l    mult_comm_ptr(a5)
  2748.     bsr    handle_mult_comms    put LF at end Allow for aliases with ;'s
  2749.     
  2750. hca_nothing_typed
  2751.     movem.l    (sp)+,d0-d2/a1-a4
  2752.     rts
  2753.  
  2754.  
  2755.     
  2756. * GET PARM line pted to by A0
  2757. * LINE MUST END IN LF THEN 0
  2758. * returns A1 pointing to the address where the parm starts
  2759. * puts a 0 over the space or lf where it ends .A0 pts to next bit on end
  2760. * return d2=0 if got all possible commands from line
  2761. get_parm    moveq    #$20,d2    D2=delimiter
  2762. get_parm1    move.l    a0,a1    ;make sure we can get the address before
  2763.     move.b    (a0)+,d1    ;skip spaces
  2764.     beq.s    last_parm2
  2765.     cmp.b    #$20,d1
  2766.     beq.s    get_parm1
  2767.     cmp.b    #$9,d1        skip tabs
  2768.     beq.s    get_parm1
  2769.     cmp.b    #LF,d1        handle idiots who type spaces at end of line
  2770.     beq.s    last_parm
  2771.     cmp.b    #'"',d1        handle double quotes
  2772.     bne.s    gp2
  2773.     addq.l    #1,a1
  2774.     moveq    #'"',d2    SET DELIMITER = "
  2775.     bra.s    gp2
  2776. gp4    cmp.b    #LF,(a0)    handle idiots who type \ at end of line
  2777.     beq.s    gp3
  2778.     addq.l    #1,a0        make sure pts to after quotes d1 is dummy
  2779. gp2    move.b    (a0)+,d1    a0 pts to after the space on exit
  2780.     cmp.b    #LF,d1
  2781.     beq.s    gp3
  2782.     cmp.b    #$5c,d1        allow for \" (nested quotes)
  2783.     beq.s    gp4
  2784.     cmp.b    d2,d1
  2785.     bne.s    gp2
  2786.     clr.b    -1(a0)        make sure last byte is 0
  2787.     rts
  2788. last_parm    clr.b -1(a0)
  2789. last_parm2    moveq #0,d2    ;signify the end
  2790.         rts
  2791. gp3    lea -1(a0),a0 if ends in LF then dont null end, catch that next time
  2792.     rts
  2793.  
  2794. **************************************************
  2795. close_redirection
  2796.     tst.b    redirect_in(a5)
  2797.     beq.s    .A
  2798.     tst.l    PipeTask(a5)        handle real pipe
  2799.     beq.s    .G
  2800. .H    move.l    inhandle(a5),d1
  2801.     lea    tempbuf(a5),a0
  2802.     move.l    a0,d2
  2803.     move.l    #2*SHELLINE_SIZE,d3
  2804.     jsr    _LVORead(a6)        read till pipe_in is empty
  2805.     tst.l    d0
  2806.     bmi.s    .G
  2807.     bne.s    .H
  2808. .G    move.l    thistask(a5),a0
  2809.     move.l    pr_CIS(a0),d1
  2810.     move.l    stdin(a5),pr_CIS(a0)    restore old stdin
  2811.     move.l    stdin(a5),inhandle(a5)
  2812.     jsr    _LVOClose(a6)
  2813. .A    tst.b    redirect_out(a5)
  2814.     beq.s    .B
  2815.     move.l    thistask(a5),a0
  2816.     move.l    pr_COS(a0),d1
  2817.     move.l    stdout(a5),pr_COS(a0)    restore old stdout
  2818.     move.l    stdout(a5),outhandle(a5)    
  2819.     jsr    _LVOClose(a6)
  2820.     tst.l    MPipePtr(a5)
  2821.     beq.s    .B
  2822.     movem.l    d2-d7/a2-a4,-(sp)
  2823.     bsr    raw_on
  2824.     sub.l    a3,a3
  2825.     bsr    viewbuffer        >M show output with more
  2826.     movem.l    (sp)+,d2-d7/a2-a4
  2827.     clr.l    MPipePtr(a5)
  2828. .B    clr.w    redirect_in(a5)        clear redirect_in and redirect_out
  2829.  
  2830.     btst    #FLpipe,Flags+2(a5)
  2831.     bne.s    .E
  2832.     lea    pipe_in(a5),a2        handle pseudo pipe
  2833.     tst.b    (a2)
  2834.     beq.s    .C
  2835.     move.l    a2,d1
  2836.     jsr    _LVODeleteFile(a6)    delete temporary file
  2837. .C    lea    pipe_out(a5),a1
  2838. .D    move.b    (a1)+,(a2)+        copy pipe_out to pipe_in
  2839.     bne.s    .D
  2840.     bra.s    .F
  2841.  
  2842. .E    tst.b    pipe_out(a5)        handle real pipe
  2843.     beq.s    .F
  2844.     move.l    4.w,a6
  2845.     moveq    #0,d0
  2846.     bset    #SIGBREAKB_CTRL_E,d0
  2847.     jsr    _LVOWait(a6)    wait for CTRL-F or till task returns
  2848.     move.l    dosbase(a5),a6
  2849. .F    clr.b    pipe_out(a5)        no pipe_out
  2850.     rts
  2851.     
  2852. * entry A0 pts to shelline
  2853. handle_redirection
  2854.     movem.l    d0/a0-a3,-(sp)
  2855.     move.l    a0,-(sp)
  2856.     lea    pipe_in(a5),a2
  2857.     tst.b    (a2)
  2858.     beq.s    .A
  2859.     move.l    #MODE_OLDFILE,d2
  2860.     bsr    redir_open2
  2861.     bsr    ChngIn
  2862. .A    lea    pipe_out(a5),a2
  2863.     tst.b    (a2)
  2864.     beq.s    .B
  2865.     move.l    #MODE_NEWFILE,d2
  2866.     bsr    redir_open2
  2867.     bsr    ChngOut
  2868. .B    move.l    (sp)+,a0
  2869.     lea    tempbuf(a5),a2
  2870. redir_2    move.b    (a0)+,d0    CHECK FOR REDIRECTION CHARS < >
  2871.     cmp.b    #LF,d0
  2872.     bne.s    .C
  2873. .F    movem.l    (sp)+,d0/a0-a3
  2874.     rts
  2875. .C    cmp.b    #'"',d0    HANDLE QUOTES
  2876.     bne.s    .A
  2877. .B    move.b    (a0)+,d0
  2878.     cmp.b    #LF,d0
  2879.     beq    .F
  2880.     cmp.b    #'"',d0
  2881.     bne.s    .B
  2882. .A    cmp.b    #$20,d0
  2883.     bne.s    redir_2
  2884.     move.b    (a0),d0    TEST CHAR AFTER SPACE.
  2885.     cmp.b    #'>',d0
  2886.     beq.s    redir_out
  2887.     cmp.b    #'<',d0
  2888.     bne.s    redir_2
  2889. redir_in
  2890.     tst.b    redirect_in(a5)
  2891.     bne    redir_twice
  2892.     move.l    #MODE_OLDFILE,d2
  2893.     cmp.b    #">",1(a0)
  2894.     beq.s    redir_both
  2895.     bsr    redir_open
  2896.     bsr    ChngIn
  2897.     move.l    a3,a0
  2898.     bra    redir_2        KEEP SEARCHING
  2899. redir_both
  2900.     bsr    redir_open
  2901.     bsr    ChngIn
  2902.     bra.s    re_out2
  2903. redir_out
  2904.     tst.b    redirect_out(a5)
  2905.     bne.s    redir_twice
  2906.     cmp.b    #">",1(a0)
  2907.     beq.s    redir_append
  2908.     lea    -1(a0),a3        ALIGN WITH SPACE
  2909.     bsr    copy_redirector
  2910.     move.b    (a2),d0
  2911.     bset    #5,d0
  2912.     cmp.b    #"m",d0
  2913.     bne.s    re_out2
  2914.     tst.b    1(a2)
  2915.     bne.s    re_out2
  2916.     clr.b    (a2)    redir to MORE, send to nil:
  2917.     move.l    ReviewPtr(a5),MPipePtr(a5)
  2918. re_out2    move.l    #MODE_NEWFILE,d2
  2919.     bsr    redir_open2
  2920.     bsr    ChngOut
  2921.     move.l    a3,a0
  2922.     bra    redir_2
  2923. redir_append
  2924.     move.l    #MODE_READWRITE,d2
  2925.     bsr    redir_open
  2926.     bsr    ChngOut
  2927.     move.l    d0,d1
  2928.     moveq    #0,d2    set position
  2929.     moveq    #1,d3    set mode
  2930.     jsr    _LVOSeek(a6)
  2931.     move.l    a3,a0
  2932.     bra    redir_2
  2933.  
  2934. redir_twice
  2935.     lea    redirtwice(pc),a0
  2936.     bsr    PrintError
  2937. redirtw    move.l    thistask(a5),a1
  2938.     bsr    SetSignalE
  2939.     bra    galactic
  2940.  
  2941. ChngIn    move.l    thistask(a5),a0
  2942.     move.l    d0,pr_CIS(a0)    MAKE STDIN DIFFERENT.
  2943.     move.l    d0,inhandle(a5)
  2944.     addq.b    #1,redirect_in(a5)
  2945.     rts
  2946. ChngOut    move.l    thistask(a5),a0
  2947.     move.l    d0,pr_COS(a0)
  2948.     move.l    d0,outhandle(a5)
  2949.     addq.b    #1,redirect_out(a5)
  2950.     rts
  2951.  
  2952. redir_open
  2953.     lea    -1(a0),a3        ALIGN WITH SPACE
  2954.     bsr    copy_redirector
  2955. redir_open2
  2956.     tst.b    (a2)
  2957.     bne.s    .B
  2958.     lea    connil(pc),a2
  2959. .B    move.b    (a2),d0
  2960.     bset    #5,d0
  2961.     cmp.b    #"w",d0
  2962.     bne.s    .C
  2963.     tst.b    1(a2)
  2964.     bne.s    .C
  2965.     lea    conname(pc),a2
  2966.     move.l    windowname(a5),d0
  2967.     beq.s    .C
  2968.     move.l    d0,a2    
  2969. .C    move.l    a2,d1
  2970.     jsr    _LVOOpen(a6)
  2971.     tst.l    d0
  2972.     bne.s    .A
  2973.     move.l    thistask(a5),a1
  2974.     bsr    SetSignalE
  2975.     bra    DOSerr
  2976. .A    rts
  2977.  
  2978. ** ENTRY A0 pts redirection symbol. A2 pts to area to save redirection name
  2979. ** EXIT A2 area holds null end string and redirection name is deleted from
  2980. **      shelline
  2981. copy_redirector
  2982.     movem.l    a0-a2,-(sp)
  2983.     move.l    a0,a1    SAVE START OF REDIRECTION STRING
  2984.     move.b    (a0)+,d0    BUMP PAST '<' or '>'
  2985. .A    move.b    (a0)+,d0
  2986.     cmp.b    #$20,d0
  2987.     beq.s    cpredsp
  2988.     cmp.b    #LF,d0
  2989.     beq.s    cpredlf
  2990.     cmp.b    #'>',d0    HANDLE APPEND REDIRECTION PROPERLY
  2991.     beq.s    .A
  2992.     move.b    d0,(a2)+    COPY NEWSTDIN/OUT TO NONSTDIN/OUT
  2993.     bra.s    .A
  2994. cpredlf    subq.l    #1,a0
  2995.     subq.l    #1,a1
  2996. cpredsp    clr.b    (a2)+    A0 should point to after the space or lf
  2997.     tst.l    mult_comm_ptr(a5)
  2998.     beq.s    .A
  2999.     move.l    a1,d0
  3000.     sub.l    a0,d0
  3001.     add.l    d0,mult_comm_ptr(a5)    offset mult_comm_ptr
  3002. .A    move.b    (a0)+,(a1)+    delete redirection string from shelline
  3003.     bne.s    .A
  3004.     movem.l    (sp)+,a0-a2
  3005.     rts
  3006.  
  3007. ** V1.14 multiple commands on command line. Delimit by ';'
  3008. * ENTRY A0 pts to shelline, EXIT A0 pts to start of next bit on line.
  3009. handle_mult_comms
  3010.     movem.l    d0/a1/a2,-(sp)
  3011.     move.l    mult_comm_ptr(a5),d0
  3012.     beq.s    .A
  3013.     move.l    d0,a0
  3014. .A    move.l    a0,a1
  3015. handle_mult_comm2
  3016. .B    move.b    (a1)+,d0
  3017.     cmp.b    #$5c,d0        is it \ ?
  3018.     beq.s    .E
  3019.     cmp.b    #'"',d0    ignore semi-colons between quotes
  3020.     bne.s    .C
  3021. .D    move.b    (a1)+,d0
  3022.     beq.s    endofline    END OF LINE IS NULL.
  3023.     cmp.b    #LF,d0
  3024.     beq.s    fndret
  3025.     cmp.b    #'"',d0
  3026.     bne.s    .D
  3027.     bra.s    .B
  3028. .E    move.b    (a1)+,d0
  3029.     bra.s    .F
  3030. .C    cmp.b    #";",d0
  3031.     beq    fndsemi
  3032.     cmp.b    #"|",d0
  3033.     bne.s    .F
  3034.     cmp.b    #" ",-2(a1)
  3035.     beq    handle_pipes
  3036. .F    cmp.b    #LF,d0
  3037.     bne.s    .B
  3038. fndret    tst.b    (a1)    IF NULL FOLLOWS LF THEN AT END OF LINE
  3039.     bne.s    fndsemi
  3040. endofline
  3041.     clr.l    mult_comm_ptr(a5)
  3042.     clr.b    pipe_count(a5)
  3043.     movem.l    (sp)+,d0/a1/a2
  3044.     rts
  3045.  
  3046. fndsemi    move.b    #LF,-1(a1)    REPLACE ; or LF with LF
  3047.     tst.l    PipeTask(a5)    is it a pipe task ?
  3048.     bne.s    endofline    yes: no mult comms
  3049.     move.l    a1,mult_comm_ptr(a5)
  3050. fndendi    movem.l    (sp)+,d0/a1/a2
  3051.     rts
  3052. handle_pipes
  3053.     btst    #FLpipe,Flags+2(a5)
  3054.     beq.s    .D
  3055.     tst.b    pipe_out(a5)
  3056.     bne.s    handle_mult_comm2    look for end of pipe
  3057. .D    move.b    #LF,-2(a1)    REPLACE space with LF
  3058.     lea    -1(a1),a2
  3059.     move.l    a2,d1
  3060.     move.l    a2,mult_comm_ptr(a5)
  3061.     move.l    a2,pipe_comm_ptr(a5)
  3062. .E    move.b    (a1)+,(a2)+    remove "|" from shelline
  3063.     bne.s    .E
  3064.     addq.b    #1,pipe_count(a5)
  3065.     lea    pipe_out(a5),a1
  3066.     lea    devpipe(pc),a2
  3067.     btst    #FLpipe,Flags+2(a5)
  3068.     bne.s    .A
  3069.     lea    devtemp(pc),a2
  3070. .A    move.b    (a2)+,(a1)+    copy "PIPE:" or "T:" to pipe_out
  3071.     bne.s    .A
  3072.     subq.l    #1,a1
  3073.     bsr    InsertCLInum
  3074.     btst    #FLpipe,Flags+2(a5)
  3075.     bne.s    .C
  3076.     move.b    pipe_count(a5),d0    append pipe number for pseudo pipes
  3077.     bsr    qpr10
  3078.     clr.b    (a1)
  3079.     bra.s    fndendi
  3080. .C    clr.b    (a1)
  3081.     move.l    d1,a1
  3082.     bra    handle_mult_comm2    look for end of pipe
  3083.  
  3084. handle_real_pipes
  3085.     btst    #FLpipe,Flags+2(a5)
  3086.     beq.s    .B
  3087.     tst.b    pipe_out(a5)
  3088.     beq.s    .B
  3089.     movem.l    d2-d7/a0-a4,-(sp)
  3090.     move.l    pipe_comm_ptr(a5),a1
  3091.     lea    tempbuf(a5),a2        create parms for new task
  3092.     move.l    a2,parm2(a5)
  3093.     move.l    #"-w*"<<8,(a2)+
  3094.     move.l    a2,parm3(a5)
  3095.     move.w    #"-c",(a2)+
  3096.     clr.l    parm4(a5)
  3097. .F    move.b    (a1)+,(a2)+
  3098.     bne.s    .F
  3099.     clr.b    -2(a2)        clear LF
  3100.     move.l    4.w,a6
  3101.     moveq    #0,d0
  3102.     moveq    #0,d1
  3103.     bset    #SIGBREAKB_CTRL_E,d1
  3104.     jsr    _LVOSetSignal(a6)    clear signal CTRL-F
  3105.     move.l    dosbase(a5),a6
  3106.     moveq    #3,d7
  3107.     bsr    create_new_cli        create new task for real pipes
  3108.     beq.s    .A
  3109.     moveq    #16,d1
  3110.     bsr    GuruIt            creation of task failed
  3111.     bra    redirtw
  3112. .A    movem.l    (sp)+,d2-d7/a0-a4
  3113. .B    rts
  3114.  
  3115. InsertCLInum
  3116.     lea    ZShellName(pc),a2
  3117. .B    move.b    (a2)+,(a1)+    append "ZShell"
  3118.     bne.s    .B
  3119.     subq.l    #1,a1
  3120.     move.l    thistask(a5),a2
  3121.     move.l    pr_TaskNum(a2),d0
  3122.     bra    qpr10        append CLI number
  3123.  
  3124. endbground
  3125.     move.l    PipeTask(a5),d0
  3126.     beq.s    .A        started with RUN
  3127.     move.l    d0,a1        task real pipe started from
  3128.     bsr    SetSignalE    tell it to end
  3129. .A    bra    cloga
  3130.  
  3131. SetSignalE        ;a1=taskaddress
  3132.     move.l    4.w,a6
  3133.     moveq    #0,d0
  3134.     bset    #SIGBREAKB_CTRL_E,d0
  3135.     jsr    _LVOSignal(a6)
  3136.     move.l    dosbase(a5),a6
  3137.     rts
  3138.  
  3139. ******************************
  3140. * Iconify Shell        V2.3 *
  3141. ******************************
  3142. WaitAppIcon
  3143.     movem.l    d2-d7/a2-a4,-(sp)
  3144.     clr.b    tempbuf(a5)
  3145.     cmp.w    #36,kickver(a5)
  3146.     blo    .G
  3147.     bsr    KillAppWin
  3148.     bsr    raw_off
  3149.     bsr    clkof2
  3150.     bsr    CloseWin
  3151.  
  3152.     tst.l    diskobj(a5)
  3153.     bne.s    .I
  3154.     bsr    OpenIconLib
  3155.     beq.s    .A
  3156.     moveq    #3,d0
  3157.     jsr    _LVOGetDefDiskObject(a6)
  3158.     move.l    d0,diskobj(a5)
  3159.     beq    .A
  3160. .I    bsr    OpenWBLib
  3161.     beq    .A
  3162.     moveq    #0,d0    opened workbench.library
  3163.     moveq    #0,d1
  3164.     move.l    app_name(a5),a0
  3165.     move.l    thistask(a5),a1
  3166.     lea    pr_MsgPort(a1),a1
  3167.     move.l    a1,d3
  3168.     sub.l    a2,a2
  3169.     move.l    diskobj(a5),a3
  3170.     sub.l    a4,a4
  3171.     jsr    _LVOAddAppIconA(a6)    add appicon
  3172.     move.l    d0,d2
  3173.     beq.s    .B
  3174.     move.l    4.w,a6
  3175. .C    move.l    d3,a0
  3176.     jsr    _LVOWaitPort(a6)    wait for one message
  3177.     bsr    GetAppIMsgs
  3178.     move.l    wbbase(a5),a6
  3179.     move.l    d2,a0
  3180.     jsr    _LVORemoveAppIcon(a6)    remove appicon
  3181. .B    bsr    GetAppIMsgs
  3182.  
  3183. .A    move.l    dosbase(a5),a6
  3184.     tst.b    openwin_flag(a5)    restore window
  3185.     beq.s    .G
  3186.     move.l    thistask(a5),a3
  3187.     move.l    CLIptr(a5),a2
  3188.     move.l    windowname(a5),d1
  3189.     clr.b    openwin_flag(a5)
  3190.     bsr    OpenWin
  3191.     beq    cloga
  3192.     jsr    _LVOOutput(a6)    SAVE THE CONSOLE HANDLERS
  3193.     move.l    d0,outhandle(a5)
  3194.     move.l    d0,stdout(a5)
  3195.     jsr    _LVOInput(a6)
  3196.     move.l    d0,inhandle(a5)
  3197.     move.l    d0,stdin(a5)
  3198.     bsr    InitAppWin
  3199.     tst.b    memclk_flag(a5)
  3200.     beq.s    .G
  3201.     bsr    clkon
  3202. .G    movem.l    (sp)+,d2-d7/a2-a4
  3203.     lea    tempbuf(a5),a1
  3204.     tst.b    (a1)
  3205.     beq.s    .D
  3206.     bsr    print_def
  3207. .D    rts
  3208.  
  3209. GetAppIMsgs
  3210.     move.l    4.w,a6
  3211. .B    move.l    d3,a0
  3212.     jsr    _LVOGetMsg(a6)        get all messages
  3213.     tst.l    d0
  3214.     beq.s    .A
  3215.     move.l    d0,a2
  3216.     cmp.w    #8,am_Type(a2)
  3217.     bne.s    .B
  3218.     bsr    ProcessApp
  3219.     move.l    a2,a1
  3220.     jsr    _LVOReplyMsg(a6)    reply them
  3221.     bra.s    .B
  3222. .A    rts
  3223.  
  3224. ProcessApp    ;Message in a2
  3225.     move.l    a2,-(sp)
  3226.     move.l    am_NumArgs(a2),d0
  3227.     move.l    am_ArgList(a2),a0
  3228.     lea    tempbuf(a5),a2
  3229.     bra.s    .D
  3230. .E    move.l    (a0)+,d1    process all args
  3231.     beq.s    .C        get name from lock to dir
  3232.     movem.l    d0-d3/a0/a3/a6,-(sp)
  3233.     move.l    dosbase(a5),a6
  3234.     jsr    _LVODupLock(a6)
  3235.     move.l    a2,a0
  3236.     bsr    eval_full_path
  3237.     jsr    _LVOUnLock(a6)
  3238. .A    tst.b    (a2)+
  3239.     bne.s    .A
  3240.     subq.l    #1,a2
  3241.     cmp.b    #":",-1(a2)
  3242.     beq.s    .B
  3243.     move.b    #"/",(a2)+    /-end path
  3244. .B    movem.l    (sp)+,d0-d3/a0/a3/a6
  3245. .C    move.l    (a0)+,d1    get filename
  3246.     beq.s    .D
  3247.     move.l    d1,a1
  3248.     bsr    addstring
  3249.     move.b    #" ",(a2)+    space-end
  3250. .D    dbra    d0,.E
  3251.     clr.b    (a2)
  3252.     move.l    (sp)+,a2
  3253.     rts
  3254.  
  3255. ** evaluate entire name associated with lock in D0, store string in A0
  3256. ** Return D1 = last lock to unlock
  3257. ** Reg usage: d0,d1,d2,d3,a0,a1,a3 (must not use A2)
  3258.  
  3259. OpenIconLib
  3260.     move.l    iconbase(a5),d0
  3261.     bne.s    .A
  3262.     move.l    4.w,a6
  3263.     lea    iconname(pc),a1
  3264.     jsr    _LVOOldOpenLibrary(a6)    icon-library
  3265.     move.l    d0,iconbase(a5)
  3266. .A    move.l    d0,a6
  3267.     rts
  3268.  
  3269. OpenWBLib
  3270.     move.l    wbbase(a5),d0
  3271.     bne.s    .A
  3272.     move.l    4.w,a6
  3273.     lea    wbname(pc),a1
  3274.     jsr    _LVOOldOpenLibrary(a6)
  3275.     move.l    d0,wbbase(a5)
  3276. .A    move.l    d0,a6
  3277.     rts
  3278.  
  3279. **********************************************
  3280. * Create CLI-Interface-Structure    V2.0 *
  3281. **********************************************
  3282. CreateCLI
  3283.     clr.b    WBflag(a5)    0=WB or CLI/1=newcli/2=run/3=pipe
  3284.     move.l    thistask(a5),a3
  3285.     move.l    pr_WindowPtr(a3),d0
  3286.     move.l    d0,oldwindowptr(a5)    preserve old winptr
  3287.     move.l    d0,windowptr(a5)    default new winptr
  3288.     tst.b    CLIflag(a5)
  3289.     beq    CCli3
  3290.     clr.l    EntryA0(a5)        started from WB
  3291.     move.l    #64+$28+$50,d0
  3292.     move.l    #MEMF_CLEAR+1,d1    memory for CLI
  3293.     bsr    iwantmem
  3294.     moveq    #1,d1
  3295.     tst.l    d0
  3296.     beq    CCli2
  3297.     move.l    d0,a2
  3298.     lsr.l    #2,d0
  3299.     move.l    d0,pr_CLI(a3)
  3300.     move.l    dl_Root(a6),a0
  3301.     move.l    (a0),a0
  3302.     add.l    a0,a0
  3303.     add.l    a0,a0
  3304.     moveq    #0,d2
  3305.     move.l    (a0),d0
  3306.     subq.l    #1,d0
  3307. .C    addq.l    #1,d2
  3308.     addq.l    #4,a0
  3309.     tst.l    (a0)        look for free CLI-Number
  3310.     dbeq    d0,.C
  3311.     moveq    #2,d1
  3312.     tst.l    (a0)
  3313.     bne    CCli2
  3314.     lea    pr_MsgPort(a3),a1
  3315.     move.l    a1,(a0)
  3316.     move.l    d2,pr_TaskNum(a3)
  3317.     moveq    #10,d0
  3318.     move.l    d0,cli_FailLevel(a2)
  3319.     moveq    #-1,d0
  3320.     move.l    d0,cli_Interactive(a2)
  3321.     move.l    #1000,cli_DefaultStack(a2)    1000 LONGs
  3322.     move.l    pr_FileSystemTask(a3),filesys_old(a5)
  3323.     lea    64(a2),a0
  3324.     move.l    a0,d0
  3325.     lsr.l    #2,d0
  3326.     move.l    d0,cli_CommandFile(a2)
  3327.     lea    64+$28(a2),a0
  3328.     move.l    a0,d0
  3329.     lsr.l    #2,d0
  3330.     move.l    d0,cli_CommandName(a2)
  3331.     IFD    DEBUG
  3332.     tst.l    wb_msg(a5)
  3333.     beq    CreateCLI2    no WB-Msg -> CreateCLI2
  3334.     ENDC
  3335.     move.l    wb_msg(a5),a0
  3336.     tst.l    sm_Process(a0)
  3337.     beq    CreateCLI3    newcli/run -> CreateCLI3
  3338.     move.l    sm_ArgList(a0),a1
  3339.     moveq    #2,d0
  3340.     cmp.l    sm_NumArgs(a0),d0
  3341.     bhi.s    .A        Project ?
  3342.     addq.l    #8,a1
  3343. .A    move.l    (a1),a0        Lock on Current Dir
  3344.     moveq    #3,d1
  3345.     move.l    a0,d0
  3346.     beq    CCli2
  3347.     move.l    a0,d1
  3348.     move.l    dosbase(a5),a6
  3349.     jsr    _LVODupLock(a6)        WB wants to free its own lock
  3350.     bsr    SetCurrentDir
  3351.     move.l    4.w,a6
  3352.     lea    wbenchtx(pc),a1
  3353.     jsr    _LVOFindTask(a6)
  3354.     tst.l    d0
  3355.     beq.s    .E
  3356.     move.l    d0,a0
  3357.     tst.l    pr_CLI(a0)
  3358.     beq.s    .E
  3359.     move.l    dosbase(a5),a6
  3360.     bsr    CopyPaths    copy paths from workbench
  3361. .E    bsr    OpenIconLib
  3362.     moveq    #4,d1
  3363.     tst.l    d0
  3364.     beq    CCli2
  3365.     move.l    d0,a4
  3366.     move.l    wb_msg(a5),a0
  3367.     move.l    sm_ArgList(a0),a1
  3368.     moveq    #2,d0
  3369.     cmp.l    sm_NumArgs(a0),d0
  3370.     bhi.s    .B            Project ?
  3371.     move.l    12(a1),d0
  3372.     beq.s    .B
  3373.     move.l    d0,EntryA0(a5)        Name of Project as Script
  3374.     addq.l    #8,a1
  3375. .B    move.l    4(a1),a0        Name of Process
  3376.     jsr    _LVOGetDiskObject(a6)
  3377.     moveq    #5,d1
  3378.     move.l    d0,diskobj(a5)
  3379.     beq    CCli2
  3380.     move.l    d0,a0
  3381.     moveq    #0,d0
  3382.     bset    #31,d0        unset icon position
  3383.     move.l    d0,$3a(a0)    CurrentX
  3384.     move.l    d0,$3e(a0)    CurrentY
  3385.     move.b    #8,$30(a0)    Type=AppIcon
  3386.     move.l    do_ToolTypes(a0),d3    d3=ToolTypes
  3387. checktooltypes
  3388.     move.l    d3,a0
  3389.     lea    xpostool(pc),a1
  3390.     jsr    _LVOFindToolType(a6)    Look for XPOS-ToolType
  3391.     tst.l    d0
  3392.     beq.s    .G
  3393.     move.l    d0,a1
  3394.     bsr    convert_ASCII_to_num
  3395.     beq.s    .G
  3396.     move.l    diskobj(a5),a0
  3397.     move.l    d0,$3a(a0)
  3398. .G    move.l    d3,a0
  3399.     lea    ypostool(pc),a1
  3400.     jsr    _LVOFindToolType(a6)    Look for YPOS-ToolType
  3401.     tst.l    d0
  3402.     beq.s    .E
  3403.     move.l    d0,a1
  3404.     bsr    convert_ASCII_to_num
  3405.     beq.s    .E
  3406.     move.l    diskobj(a5),a0
  3407.     move.l    d0,$3e(a0)
  3408. .E    move.l    d3,a0
  3409.     lea    nametool(pc),a1
  3410.     jsr    _LVOFindToolType(a6)    Look for ICONNAME-ToolType
  3411.     tst.l    d0
  3412.     beq.s    .C
  3413.     move.l    d0,app_name(a5)
  3414. .C    move.l    d3,a0
  3415.     lea    iconifytool(pc),a1
  3416.     jsr    _LVOFindToolType(a6)    Look for ICONIFY-ToolType
  3417.     tst.l    d0
  3418.     beq.s    .B
  3419.     bset    #FLappicon,Flags+3(a5)
  3420.     movem.l    d2-d5/a6,-(sp)
  3421.     moveq    #0,d4
  3422.     moveq    #0,d5
  3423.     bsr    WaitAppIcon
  3424.     movem.l    (sp)+,d2-d5/a6
  3425. .B    move.l    d3,a0
  3426.     lea    screentool(pc),a1
  3427.     jsr    _LVOFindToolType(a6)    Look for SCREEN-ToolType
  3428.     move.l    d0,pubname(a5)
  3429.     move.l    d3,a0
  3430.     lea    wintool(pc),a1
  3431.     jsr    _LVOFindToolType(a6)    Look for WINDOW-ToolType
  3432.     lea    conname(pc),a0
  3433.     tst.l    d0
  3434.     beq.s    .D
  3435.     move.l    d0,a0
  3436. .D    move.l    a0,d1
  3437.     move.l    dosbase(a5),a6
  3438.     bsr    OpenWin            Open Window
  3439.     beq    CCli2a
  3440.     move.l    d3,a0
  3441.     lea    scripttool(pc),a1
  3442.     move.l    a4,a6
  3443.     jsr    _LVOFindToolType(a6)    Look for SCRIPT-ToolType
  3444.     tst.l    EntryA0(a5)    project ?
  3445.     bne.s    .F
  3446.     move.l    d0,EntryA0(a5)
  3447. .F    move.l    d3,a0
  3448.     lea    norawtool(pc),a1
  3449.     jsr    _LVOFindToolType(a6)    Look for NORAW-ToolType
  3450.     tst.l    d0
  3451.     beq.s    .A
  3452.     clr.l    ConsoleSwitch(a5)
  3453. .A    move.l    d3,a0
  3454.     lea    helptool(pc),a1
  3455.     jsr    _LVOFindToolType(a6)    Look for HELPMAN-ToolType
  3456.     tst.l    d0
  3457.     beq.s    .H
  3458.     move.l    d0,online_help(a5)
  3459. .H    move.l    d3,a0
  3460.     lea    commandtool(pc),a1
  3461.     jsr    _LVOFindToolType(a6)    Look for COMMAND-ToolType
  3462.     move.l    d0,d2
  3463.     bsr    Com2Script
  3464. CCli1    move.l    dosbase(a5),a6
  3465.     moveq    #0,d0
  3466.     rts
  3467. CCli2    bsr    GuruIt
  3468. CCli2a    move.l    dosbase(a5),a6
  3469.     moveq    #-1,d0
  3470.     rts
  3471.  
  3472. CCli3    move.l    pr_COS(a3),outhandle(a5)    started from CLI
  3473.     move.l    pr_ConsoleTask(a3),ConsoleSwitch(a5)
  3474.     move.l    pr_CurrentDir(a3),d1
  3475.     bne.s    .D
  3476.     moveq    #-2,d2
  3477.     jsr    _LVOLock(a6)
  3478.     tst.l    d0
  3479.     beq    .D
  3480.     bsr    SetCurrentDir
  3481. .D    move.l    EntryA0(a5),d0    process CLI-Command-Line
  3482.     beq.s    CCli1
  3483.     clr.l    EntryA0(a5)
  3484.     move.l    d0,a0
  3485.     lea    parm2(a5),a2
  3486.     lea    endofparms(a5),a4    establish end of parms block
  3487. .A    bsr    get_parm        
  3488.     tst.l    d2
  3489.     beq.s    .B
  3490.     move.l    a1,(a2)+
  3491.     cmp.l    a2,a4        get out if more than 25 parms
  3492.     bne.s    .A
  3493.     clr.b    (a0)        make sure last parm ends in 0
  3494. .B    lea    parm2(a5),a1
  3495.     bsr.s    StartOpts
  3496.     bne.s    CCli2a
  3497.     tst.l    d3
  3498.     beq.s    .C
  3499.     clr.l    ConsoleSwitch(a5)
  3500. .C    tst.l    d1
  3501.     beq.s    CCli1
  3502.     move.l    thistask(a5),a3
  3503.     move.l    pr_CLI(a3),a2
  3504.     add.l    a2,a2
  3505.     add.l    a2,a2
  3506.     bsr    OpenWin
  3507.     tst.l    d0
  3508.     beq.s    CCli2a
  3509.     tst.l    d3
  3510.     beq    CCli1
  3511.     clr.l    ConsoleSwitch(a5)
  3512.     bra    CCli1
  3513.  
  3514. StartOpts        ;examine startup-options, parms in a1
  3515.     moveq    #0,d1    returns window in d1, script in EntryA0
  3516.     moveq    #0,d2    and start-command in d2
  3517.     moveq    #0,d3    d3>0 if noraw, screen in pubname
  3518. .A    move.l    (a1)+,d0
  3519.     beq.s    Com2Script    exit to Com2Script
  3520.     move.l    d0,a0
  3521.     cmp.b    #"-",(a0)+
  3522.     bne.s    .H
  3523.     move.b    (a0)+,d0
  3524.     or.b    #$20,d0
  3525.     cmp.b    #"s",d0        -s for Script
  3526.     bne.s    .B
  3527.     move.l    a0,EntryA0(a5)
  3528.     bra.s    .A
  3529. .B    cmp.b    #"w",d0        -w for Window
  3530.     bne.s    .C
  3531.     move.l    a0,d1
  3532.     bra.s    .A
  3533. .C    cmp.b    #"c",d0        -c for Command
  3534.     bne.s    .D
  3535.     move.l    a0,d2
  3536.     bra.s    .A
  3537. .D    cmp.b    #"d",d0        -d for detach
  3538.     bne.s    .E
  3539.     clr.l    -4(a1)
  3540.     bsr    initialise_default
  3541.     bsr    newcliz
  3542.     bra.s    .I
  3543. .E    cmp.b    #"r",d0        -r for not Resident
  3544.     beq.s    .A
  3545.     cmp.b    #"n",d0        -n for Noraw
  3546.     bne.s    .F
  3547.     moveq    #1,d3
  3548.     bra.s    .A
  3549. .F    cmp.b    #"e",d0        -e for scrEen
  3550.     bne.s    .H
  3551.     move.l    a0,pubname(a5)
  3552.     bra.s    .A
  3553. .H    cmp.b    #"h",d0        -h for Helpman
  3554.     bne.s    .J
  3555.     move.l    a0,online_help(a5)
  3556.     bra.s    .A
  3557. .J    lea    useit(pc),a1
  3558.     bsr    pr_stringlf
  3559. .I    moveq    #-1,d0
  3560.     rts
  3561.  
  3562. Com2Script        ;Makes a command to script, d2=command
  3563.     move.l    d1,-(sp)    returns d0=0 for OK
  3564.     tst.l    d2        V2.7: uses mult_comm_ptr, cannot fail
  3565.     beq.s    .B
  3566.     lea    null(pc),a0
  3567.     move.l    a0,EntryA0(A5)    no (default) script
  3568.     move.l    d2,a0
  3569.     lea    shelline(a5),a1
  3570.     move.l    a1,mult_comm_ptr(a5)
  3571. .D    move.b    (a0)+,(a1)+    copy command to shelline
  3572.     bne.s    .D
  3573.     move.b    #LF,-1(a1)
  3574.     clr.b    (a1)
  3575. .B    move.l    (sp)+,d1
  3576.     moveq    #0,d0
  3577.     rts
  3578.  
  3579. SetCurrentDir    ;lock in d0
  3580.     move.l    d0,a0
  3581.     add.l    a0,a0
  3582.     add.l    a0,a0
  3583.     move.l    fl_Task(a0),pr_FileSystemTask(a3)
  3584.     move.l    d0,d1
  3585.     jsr    _LVOCurrentDir(a6)
  3586.     move.l    d0,cdir_old(a5)
  3587.     rts
  3588.  
  3589. * Create CLI-Interface-Structure without WB-Message    V2.0 *
  3590.     IFD    DEBUG
  3591. CreateCLI2
  3592.     lea    conname(pc),a0
  3593.     move.l    a0,d1
  3594.     bsr    OpenWin
  3595.     beq.s    .B
  3596.     lea    ramdisk(pc),a0
  3597.     move.l    a0,d1
  3598.     moveq    #-2,d2
  3599.     jsr    _LVOLock(a6)
  3600.     tst.l    d0
  3601.     beq    .B
  3602.     bsr    SetCurrentDir
  3603.     moveq    #0,d0
  3604.     rts
  3605. .B    moveq    #-1,d0
  3606.     rts
  3607.  
  3608. ramdisk    dc.b    "RAM:",0
  3609.     even
  3610.     ENDC
  3611.  
  3612. * Create CLI-Interface-Structure with special message    V2.0
  3613. * ENTRY: a0:wb_msg, a2:CLI_Struct, a3:Process
  3614. *sm_NumArgs:    General Memory Block
  3615. *sm_ToolWindow:    Mode (1=newcli, 2=run, 3=pipe)
  3616. CreateCLI3
  3617.     move.b    sm_ToolWindow(a0),WBflag(a5)    not started from WB
  3618.     move.l    sm_NumArgs(a0),a4    wb_msg in a0
  3619.     move.l    Flags(a4),Flags(a5)
  3620.     move.l    copysize(a4),copysize(a5)
  3621.     move.l    FNCsize(a4),FNCsize(a5)
  3622.     move.l    app_name(a4),app_name(a5)
  3623.     move.l    online_help(a4),online_help(a5)
  3624.     move.l    pubname(a4),pubname(a5)
  3625.     move.l    thistask(a4),a0
  3626.     move.l    pr_CurrentDir(a0),d1
  3627.     move.l    pr_CLI(a0),a0
  3628.     add.l    a0,a0
  3629.     add.l    a0,a0
  3630.     move.l    cli_DefaultStack(a0),cli_DefaultStack(a2)
  3631.     move.l    cli_FailLevel(a0),cli_FailLevel(a2)
  3632.     jsr    _LVODupLock(a6)        COPY CD
  3633.     moveq    #15,d1
  3634.     tst.l    d0
  3635.     beq    cce3
  3636.     bsr    SetCurrentDir
  3637.     move.l    outhandle(a4),outhandle(a5)    PROCESS PARMS
  3638.     lea    parm2(a4),a1
  3639.     bsr    StartOpts
  3640.     clr.l    outhandle(a5)
  3641.     tst.l    d0
  3642.     bne    cce2
  3643.     move.l    thistask(a4),a0        OPEN WINDOW
  3644.     move.l    pr_ConsoleTask(a0),pr_ConsoleTask(a3)
  3645.     cmp.b    #2,WBflag(a5)
  3646.     bne.s    .K
  3647.     tst.b    redirect_out(a4)    out-redirected run command ?
  3648.     beq.s    .K
  3649.     tst.l    outhandle(a4)
  3650.     beq.s    .K
  3651.     move.l    outhandle(a4),a0
  3652.     add.l    a0,a0
  3653.     add.l    a0,a0
  3654.     move.l    fh_Type(a0),d0
  3655.     move.l    d0,pr_ConsoleTask(a3)
  3656. .K    lea    conname(pc),a0
  3657.     tst.l    d1
  3658.     bne.s    .H
  3659.     move.l    a0,d1
  3660.     move.l    windowname(a4),d0
  3661.     beq.s    .H
  3662.     move.l    d0,d1
  3663. .H    bsr    OpenWin
  3664.     beq    cce2
  3665.     cmp.b    #2,WBflag(a5)
  3666.     beq.s    .J
  3667.     tst.l    d3
  3668.     beq.s    .B
  3669. .J    clr.l    ConsoleSwitch(a5)
  3670. .B    move.l    thistask(a4),a0            COPY SEARCH PATHS
  3671.     bsr    CopyPaths
  3672.     lea    prompt_args(a4),a0    COPY PROMPT
  3673.     lea    prompt_args(a5),a1
  3674. .G    move.b    (a0)+,(a1)+
  3675.     bne.s    .G
  3676.     lea    now(a4),a0        COPY HISTORY
  3677.     lea    now(a5),a1
  3678.     move.w    #HISTORY_SIZE+12-1,d0
  3679. .D    move.b    (a0)+,(a1)+
  3680.     dbra    d0,.D
  3681.     moveq    #ctrl_inite-ctrl_init-1,d0    COPY CTRL-CODES
  3682.     lea    ctrl_codes-1(a4),a0
  3683.     lea    ctrl_codes-1(a5),a1
  3684. .E    move.b    (a0)+,(a1)+
  3685.     dbra    d0,.E
  3686.     moveq    #more_inite-more_init-1,d0    COPY MORE-KEYS
  3687.     lea    morekeys(a4),a0
  3688.     lea    morekeys(a5),a1
  3689. .I    move.b    (a0)+,(a1)+
  3690.     dbra    d0,.I
  3691.     lea    FNCignore(a4),a0        COPY FNC-ignore
  3692.     lea    FNCignore(a5),a1
  3693. .F    move.b    (a0)+,(a1)+
  3694.     bne    .F
  3695. ccs1    movem.l    a2-a4,-(sp)    COPY ALL ALIASES
  3696.     moveq    #0,d3        Link Pointer
  3697.     move.l    first_set_defn(a4),d0    old aliases
  3698.     beq    .A
  3699. .B    move.l    d0,a3
  3700.     move.l    set_size(a3),d0
  3701.     move.l    d0,d2
  3702.     moveq    #1,d1
  3703.     bsr    iwantmem    get mem for set
  3704.     beq.s    .A
  3705.     move.l    d0,a2
  3706.     move.l    a3,a0        copy whole set
  3707.     move.l    a2,a1
  3708.     move.l    d2,d1
  3709.     subq.l    #1,d2
  3710. .C    move.b    (a0)+,(a1)+
  3711.     dbra    d2,.C
  3712.     move.l    d1,set_size(a2)    init set
  3713.     move.l    d3,(a2)
  3714.     move.l    a2,d3
  3715.     move.l    (a3),d0        check next set address
  3716.     bne    .B
  3717. .A    move.l    d3,first_set_defn(a5)
  3718.     cmp.b    #2,WBflag(a5)        CREATE REVIEW-BUFFER
  3719.     bhs.s    .D
  3720.     move.l    ReviewSize(a4),d0
  3721.     beq.s    .D
  3722.     bsr    MakeReview
  3723. .D    movem.l    (sp)+,a2-a4
  3724. ccs2    cmp.b    #2,WBflag(a5)        BACKGROUND PROCESS
  3725.     blo.s    .D
  3726.     moveq    #-1,d0
  3727.     move.l    d0,cli_Background(a2)
  3728.     cmp.b    #3,WBflag(a5)        COPY PIPENAME
  3729.     bne.s    .D
  3730.     lea    pipe_out(a4),a0
  3731.     lea    pipe_in(a5),a1
  3732. .E    move.b    (a0)+,(a1)+
  3733.     bne.s    .E
  3734.     clr.l    ConsoleSwitch(a5)
  3735.     move.l    thistask(a4),PipeTask(a5)
  3736. .D    move.l    EntryA0(a5),d0        SCRIPT GIVEN ?
  3737.     beq.s    .A
  3738.     move.l    d0,a0
  3739.     lea    prompt_string(a5),a1    there is enough place
  3740.     move.l    a1,EntryA0(a5)
  3741. .B    move.b    (a0)+,(a1)+    Copy Script-Parm
  3742.     bne.s    .B
  3743. .A    moveq    #RETURN_OK,d0
  3744.     bra.s    cce1
  3745. cce3    bsr    GuruIt
  3746. cce2    moveq    #RETURN_ERROR,d0
  3747. cce1    move.l    d0,-(sp)
  3748.     move.l    4.w,a6
  3749.     move.l    wb_msg(a5),a1
  3750.     move.l    d0,sm_ToolWindow(a1)    return success to calling task
  3751.     jsr    _LVOReplyMsg(a6)
  3752.     clr.l    wb_msg(a5)
  3753.     move.l    dosbase(a5),a6
  3754.     move.l    (sp)+,d0
  3755.     rts
  3756.  
  3757. *************************************************************
  3758. * Open Window for both Input and Output, Name in d1 , a2,a3 *
  3759. *************************************************************
  3760. OpenWin    move.l    dosbase(a5),a6
  3761.     moveq    #0,d0
  3762.     cmp.b    #1,openwin_flag(a5)
  3763.     beq    .C
  3764.     move.b    #1,openwin_flag(a5)
  3765.     move.l    pr_CIS(a3),OldCIS(a5)
  3766.     move.l    pr_COS(a3),OldCOS(a5)
  3767.     clr.l    pr_CIS(a3)        avoid freeing it
  3768.     clr.l    pr_COS(a3)
  3769.     move.l    pr_ConsoleTask(a3),OldCTask(a5)
  3770.     clr.l    ConsoleSwitch(a5)
  3771.     move.l    d1,a0
  3772.     move.l    a0,windowname(a5)
  3773.     tst.b    (a0)
  3774.     beq    .A            NIL:
  3775.     cmp.w    #36,kickver(a5)
  3776.     blo    .D
  3777.     move.l    pubname(a5),d0
  3778.     beq    .D
  3779.  
  3780.     movem.l    d1-d2/a2,-(sp)    open Public Screen
  3781.     lea    PubTags(pc),a0
  3782.     lea    temp2buf(a5),a1        copy tags-field
  3783.     move.l    a1,a2
  3784. .E    move.l    (a0)+,(a1)+
  3785.     clr.l    (a1)+
  3786.     tst.l    -8(a1)
  3787.     bne.s    .E
  3788.     move.l    d0,a1
  3789.     moveq    #2,d0
  3790.     addq.l    #1,a1
  3791.     tst.b    -1(a1)
  3792.     beq.s    .H
  3793.     subq.l    #1,a1
  3794.     bsr    convert_ASCII_to_num
  3795. .H    move.l    d0,1*4(a2)    Depth
  3796.     move.l    #$8000,d0
  3797.     tst.b    -1(a1)
  3798.     beq.s    .I
  3799.     bsr    convert_ASCII_to_num
  3800. .I    move.l    d0,9*4(a2)    DisplayID
  3801.     moveq    #1,d0
  3802.     tst.b    -1(a1)
  3803.     beq.s    .J
  3804.     bsr    convert_ASCII_to_num
  3805. .J    move.l    d0,11*4(a2)    Overscan
  3806.     lea    ZShellName(pc),a0    fill up tags-field
  3807.     tst.b    -1(a1)
  3808.     beq.s    .G
  3809.     move.l    a1,a0
  3810. .G    move.l    a0,3*4(a2)    Screentitle
  3811.     move.l    a0,7*4(a2)
  3812.     moveq    #2,d0
  3813.     move.l    d0,5*4(a2)    Pubscreen
  3814.     moveq    #12,d0
  3815.     move.l    d0,13*4(a2)    PubSig=ctrl-C
  3816.     lea    PenAray(pc),a0
  3817.     move.l    a0,15*4(a2)    Drawinfo
  3818.     move.l    a2,a1
  3819.     sub.l    a0,a0
  3820.     move.l    intuibase(a5),a6
  3821.     jsr    _LVOOpenScreenTagList(a6)    open Screen
  3822.     move.l    d0,pubscreen(a5)
  3823.     beq.s    .F
  3824.     move.l    d0,a0
  3825.     moveq    #0,d0
  3826.     jsr    _LVOPubScreenStatus(a6)    make Pubscreen public
  3827. .F    move.l    dosbase(a5),a6
  3828.     movem.l    (sp)+,d1-d2/a2
  3829.  
  3830. .D    cmp.b    #2,WBflag(a5)
  3831.     bne.s    .L
  3832.     move.l    temp4(a4),d0        use outhandle of RUN command
  3833.     bne.s    .M
  3834. .L    move.l    #MODE_NEWFILE,d2
  3835.     jsr    _LVOOpen(a6)        open output-Window
  3836. .M    moveq    #11,d1
  3837.     move.l    d0,pr_COS(a3)
  3838.     beq    .B
  3839.     move.l    d0,d1
  3840.     move.l    d0,cli_StandardOutput(a2)
  3841.     move.l    d0,cli_CurrentOutput(a2)
  3842.     lsl.l    #2,d0
  3843.     move.l    d0,-(sp)
  3844.     jsr    _LVOIsInteractive(a6)
  3845.     moveq    #12,d1
  3846.     move.l    (sp)+,a0
  3847.     tst.l    d0
  3848.     bne.s    .K
  3849.     cmp.b    #2,WBflag(a5)    NIL: output on RUN command ?
  3850.     beq.s    .A
  3851.     bra.s    .B
  3852. .K    move.l    fh_Type(a0),d0
  3853.     move.l    d0,pr_ConsoleTask(a3)
  3854.     move.l    d0,ConsoleSwitch(a5)
  3855.     lea    star(pc),a0
  3856.     move.l    a0,d1
  3857.     move.l    #MODE_OLDFILE,d2
  3858.     jsr    _LVOOpen(a6)        open input-window
  3859.     moveq    #13,d1
  3860.     move.l    d0,pr_CIS(a3)
  3861.     beq    .B
  3862.     move.l    d0,cli_StandardInput(a2)
  3863.     move.l    d0,cli_CurrentInput(a2)
  3864.     bsr    GetWindowPtr
  3865.     beq.s    .A
  3866.     move.l    d0,windowptr(a5)
  3867.     move.l    d0,pr_WindowPtr(a3)
  3868. .A    moveq    #-1,d0
  3869.     rts            d0<>0 if OK
  3870. .C    moveq    #10,d1
  3871. .B    bra    GuruIt        d0=0 on error
  3872.  
  3873. PubTags    dc.l    $80000000+37    Depth=2/1
  3874.     dc.l    $80000000+40    Title=*ZShell/3
  3875.     dc.l    $80000000+45    Type=Publicscreen/5
  3876.     dc.l    $80000000+47    PubName=*ZShell/7
  3877.     dc.l    $80000000+50    DisplayID=Hires/9
  3878.     dc.l    $80000000+52    Overscan=1/11
  3879.     dc.l    $80000000+48    PubSig=12/13
  3880.     dc.l    $80000000+58    Pens=*PenArray/15
  3881.     dc.l    0
  3882. PenAray    dc.w    0,-1
  3883.  
  3884. *******************************
  3885. CloseWin
  3886.     move.l    thistask(a5),a3
  3887.     tst.b    openwin_flag(a5)
  3888.     beq.s    .A
  3889.     move.l    pr_CIS(a3),d1
  3890.     beq.s    .C
  3891.     jsr    _LVOClose(a6)    close input-window
  3892. .C    move.l    pr_COS(a3),d1
  3893.     beq.s    .D
  3894.     jsr    _LVOClose(a6)    close output-window
  3895. .D    move.l    OldCIS(a5),d0
  3896.     move.l    d0,pr_CIS(a3)
  3897.     move.l    OldCOS(a5),d1
  3898.     move.l    d1,pr_COS(a3)
  3899.     move.l    OldCTask(a5),pr_ConsoleTask(a3)
  3900.     tst.l    pr_CLI(a3)
  3901.     beq.s    .G
  3902.     move.l    pr_CLI(a3),a2
  3903.     add.l    a2,a2
  3904.     add.l    a2,a2
  3905.     move.l    d0,cli_StandardInput(a2)
  3906.     move.l    d0,cli_CurrentInput(a2)
  3907.     move.l    d1,cli_StandardOutput(a2)
  3908.     move.l    d1,cli_CurrentOutput(a2)
  3909. .G    move.l    pubscreen(a5),d0
  3910.     beq.s    .A
  3911.     move.l    d0,a0
  3912.     move.l    intuibase(a5),a6
  3913.     jsr    _LVOCloseScreen(a6)    close Public Screen
  3914.     tst.l    d0
  3915.     bne.s    .A
  3916.     move.l    4.w,a6
  3917.     moveq    #0,d0
  3918.     bset    #SIGBREAKB_CTRL_C,d0
  3919.     jsr    _LVOWait(a6)
  3920.     bra.s    .G
  3921. .A    move.l    dosbase(a5),a6
  3922.     rts
  3923.  
  3924. **********************************************
  3925. * Remove CLI-Interface-Structure    V2.0 *
  3926. **********************************************
  3927. RemoveCLI
  3928.     move.l    thistask(a5),a3
  3929.     IFD    KILL
  3930.     cmp.w    #36,kickver(a5)
  3931.     blo.s    .G
  3932.     clr.l    pr_ExitCode(a3)
  3933. .G    ENDC
  3934.     move.l    oldwindowptr(a5),pr_WindowPtr(a3)
  3935.     move.l    old_homedir(a5),d0
  3936.     beq.s    .B
  3937.     move.l    d0,pr_HomeDir(a3)
  3938. .B
  3939.     bsr    clkoff
  3940.     bsr    CloseWin
  3941.     move.l    diskobj(a5),d0
  3942.     beq.s    .F
  3943.     move.l    d0,a0
  3944.     move.l    iconbase(a5),a6
  3945.     jsr    _LVOFreeDiskObject(a6)
  3946. .F    move.l    4.w,a6
  3947.     move.l    iconbase(a5),d0
  3948.     beq.s    .A
  3949.     move.l    d0,a1
  3950.     jsr    _LVOCloseLibrary(a6)
  3951. .A    move.l    wbbase(a5),d0
  3952.     beq.s    .C
  3953.     move.l    d0,a1
  3954.     jsr    _LVOCloseLibrary(a6)
  3955. .C    move.l    utilbase(a5),d0
  3956.     beq.s    .D
  3957.     move.l    d0,a1
  3958.     jsr    _LVOCloseLibrary(a6)
  3959. .D    move.l    dosbase(a5),a6
  3960.     move.l    pr_CLI(a3),d0
  3961.     beq    remend
  3962.     lsl.l    #2,d0
  3963.     move.l    d0,a2
  3964.     moveq    #10,d0
  3965.     move.l    d0,cli_FailLevel(a2)
  3966.     move.l    old_setname(a5),d0
  3967.     beq.s    remcli
  3968.     move.l    d0,cli_SetName(a2)
  3969.     lsl.l    #2,d0
  3970.     move.l    d0,a1
  3971.     lea    CD_string(a5),a0
  3972. .E    move.b    (a0)+,(a1)+    copy current dir name
  3973.     bne.s    .E
  3974.     move.l    old_prompt(a5),cli_Prompt(a2)
  3975.  
  3976. remcli    tst.b    CLIflag(a5)
  3977.     beq.s    remend
  3978.     clr.l    pr_CLI(a3)    clear CLI-Pointer
  3979.     move.l    pr_TaskNum(a3),d0
  3980.     beq.s    .E
  3981.     lsl.l    #2,d0
  3982.     move.l    dl_Root(a6),a0
  3983.     move.l    (a0),a0
  3984.     add.l    a0,a0
  3985.     add.l    a0,a0
  3986.     add.l    d0,a0
  3987.     clr.l    (a0)        free task-number
  3988.     clr.l    pr_TaskNum(a3)
  3989. .E    lea    cli_CommandDir(a2),a4
  3990.     bsr    DeletePaths    free search paths
  3991.     move.l    cdir_old(a5),d1
  3992.     jsr    _LVOCurrentDir(a6)
  3993.     move.l    d0,d1
  3994.     beq.s    .B
  3995.     jsr    _LVOUnLock(a6)    free current dir
  3996. .B    move.l    filesys_old(a5),pr_FileSystemTask(a3)
  3997.     clr.l    pr_Result2(a3)
  3998.     move.l    #64+$28+$50,d0
  3999.     move.l    a2,a1
  4000.     bsr    givemem        free memory of CLI
  4001. remend    move.l    dosbase(a5),a6
  4002.     rts
  4003.  
  4004. **************************************************************
  4005. GuruIt    ;get errornumber in d1 and display a recoverable alert
  4006.     movem.l    d0-d1/a0-a2/a6,-(sp)
  4007.     lea    tempbuf(a5),a0
  4008.     move.l    a0,a1
  4009.     clr.b    (a1)+
  4010.     move.b    #250,(a1)+
  4011.     move.b    #15,(a1)+
  4012.     lea    ZShellName(pc),a2
  4013. .A    move.b    (a2)+,(a1)+
  4014.     bne.s    .A
  4015.     move.b    #" ",-1(a1)
  4016.     move.l    d1,d0
  4017.     bsr    qpr10
  4018.     clr.b    (a1)+
  4019.     clr.b    (a1)+
  4020.     move.l    intuibase(a5),a6
  4021.     moveq    #0,d0
  4022.     moveq    #35,d1
  4023.     jsr    _LVODisplayAlert(a6)
  4024.     movem.l    (sp)+,d0-d1/a0-a2/a6
  4025.     tst.l    d0
  4026.     rts
  4027.  
  4028. *CHECK WHETHER THERE IS ENOUGH STACK FREE    V2.0 *
  4029. ;d0=requested stacksize
  4030. stacktest movem.l    d0-d1/a0-a1,-(sp)
  4031.     move.l    topstack(a5),a0
  4032.     sub.l    sp,a0
  4033.     move.l    a0,d1
  4034.     add.l    d0,d1
  4035.     add.l    #1600,d1    ;allow some bytes for DOS
  4036.     cmp.l    stacksize(a5),d1
  4037.     blo.s    .A
  4038.     lea    stack_tx(pc),a0
  4039.     bsr    PrintError
  4040.     moveq    #-1,d0
  4041.     bra.s    .B
  4042. .A    moveq    #0,d0
  4043. .B    movem.l    (sp)+,d0-d1/a0-a1
  4044.     rts
  4045.  
  4046. bad_number_error
  4047.     moveq    #115,d0
  4048.     bra.s    pr_galactic
  4049.  
  4050. too_less_args
  4051.     moveq    #116,d0
  4052.     bra.s    pr_galactic
  4053.  
  4054. *SendPacket-Error-Tester
  4055. PKTerr    tst.l    sp_res1(a5)
  4056.     bne    .A
  4057.     move.l    sp_res2(a5),d0
  4058.     bra.s    pr_galactic
  4059. .A    rts
  4060. *DOSERRor but Unlock first using D7 as the lock
  4061. DOSerrUL    move.l d7,d1        ;Assume D7=lock
  4062.     beq.s    DOSerr
  4063.     move.l    thistask(a5),a2
  4064.     move.l    pr_Result2(a2),d2
  4065.     jsr    _LVOUnLock(a6)
  4066.     move.l    d2,pr_Result2(a2)
  4067. *DOSERRor handler
  4068. DOSerr    jsr    _LVOIoErr(a6)
  4069.     cmp.l    #232,d0
  4070.     bne.s    pr_galactic
  4071.     moveq    #0,d0
  4072.     rts            ;Return if ERROR_NO_MORE_ENTRIES
  4073.  
  4074. pr_galactic
  4075.     bsr.s    pr_DOSerr    ;entry for dospacket
  4076. galactic
  4077.     move.l    errorstack(a5),sp    ;restore stack
  4078.     moveq    #RETURN_BAD,d0
  4079.     bra    chkfail        ;reenter shell loop
  4080.  
  4081. maybeDOSerr    ;checks if d0=0, then prints DOSerr
  4082.     move.l    d0,-(sp)
  4083.     bne.s    .A
  4084.     jsr    _LVOIoErr(a6)
  4085.     bsr    pr_DOSerr        error occured
  4086. .A    move.l    (sp)+,d0
  4087.     rts
  4088.  
  4089. * ENTRY D0=dos error number
  4090. pr_DOSerr
  4091.     move.l    a2,-(sp)
  4092.     move.l    d0,-(sp)
  4093.     bsr    pr_DOSerr1
  4094.     bsr    GetMessage
  4095.     bsr    pr_DOSerr2
  4096.     tst.l    d0
  4097.     bne.s    .A
  4098.     move.l    #-155,d0
  4099.     bsr    GetMessage
  4100.     move.l    sp,a1
  4101.     bsr    new_print
  4102. .A    lea    lf(pc),a1
  4103.     bsr    pr_error
  4104.     addq.l    #4,sp
  4105.     move.l    (sp)+,a2
  4106.     moveq    #RETURN_ERROR,d0
  4107.     rts
  4108.  
  4109. pr_DOSerr1
  4110.     lea    NewPrintBuffer(a5),a2
  4111.     lea    farb2(pc),a1
  4112.     bsr    addstring
  4113.     move.l    parm1(a5),a1
  4114.     bsr    addstring
  4115.     move.b    #":",(a2)+
  4116.     move.b    #" ",(a2)+
  4117.     rts
  4118.  
  4119. pr_DOSerr2
  4120.     move.l    a0,a1
  4121.     bsr    addstring
  4122.     lea    farb1(pc),a1
  4123.     bsr    addstring
  4124.     lea    NewPrintBuffer(a5),a1
  4125.     bsr    pr_error
  4126.     rts
  4127.  
  4128. PrintError    ;string to print in a0
  4129.     move.l    a2,-(sp)
  4130.     bsr    pr_DOSerr1
  4131.     bsr    pr_DOSerr2
  4132.     lea    lf(pc),a1
  4133.     bsr    pr_error
  4134.     move.l    (sp)+,a2
  4135.     moveq    #RETURN_ERROR,d0
  4136.     rts
  4137.  
  4138. pr_prompt lea prompt_string(a5),a1
  4139. pr_error
  4140.     move.l    outhandle(a5),-(sp)
  4141.     move.l    stdout(a5),outhandle(a5)
  4142.     bsr    pr_string
  4143.     move.l    (sp)+,outhandle(a5)
  4144.     rts
  4145.  
  4146. GetMessage
  4147.     cmp.w    #36,kickver(a5)
  4148.     blo.s    .E
  4149.     movem.l    d2-d4,-(sp)    OS2.0+ stuff
  4150.     move.l    d0,d1
  4151.     lea    null(pc),a0
  4152.     move.l    a0,d2
  4153.     lea    gather(a5),a0
  4154.     clr.b    2(a0)
  4155.     move.l    a0,d3
  4156.     moveq    #80,d4
  4157.     jsr    _LVOFault(a6)
  4158.     movem.l    (sp)+,d2-d4
  4159.     lea    gather+2(a5),a0
  4160.     rts
  4161. .E    lea    doserror_text(pc),a0    OS1.3- stuff
  4162.     bra.s    .C
  4163. .B    tst.b    (a0)+
  4164.     bne.s    .B
  4165. .C    move.b    (a0)+,d1
  4166.     beq.s    .A
  4167.     cmp.b    d1,d0
  4168.     bne.s    .B
  4169.     rts
  4170. .A    moveq    #0,d0
  4171.     rts
  4172.  
  4173. * fix up parameters that exist or not
  4174. fixpam32    move.l parm3(a5),d0
  4175.     move.l    d0,a1
  4176.     bne.s    fixpam2
  4177.     lea    null(pc),a1
  4178.     move.l    a1,parm3(a5)
  4179. fixpam2    move.l    parm2(a5),d0
  4180.     move.l    d0,a0
  4181.     bne.s    fxpam
  4182.     lea    null(pc),a0
  4183.     move.l    a0,parm2(a5)
  4184. fxpam    rts
  4185.     
  4186. *************************
  4187. *    RENAME        *
  4188. *************************
  4189. renamez    bsr    fixpam32
  4190. ;DON'T PUT ANYTHING HERE
  4191.     * A0-> oldname  A1-> newname
  4192. rename    move.l    a0,d1
  4193.     move.l    a1,d2
  4194.     jsr    _LVORename(a6)
  4195.     tst.l    d0
  4196.     beq    DOSerr
  4197.     moveq    #RETURN_OK,d0
  4198.     rts
  4199.  
  4200. *************************
  4201. *    MAKEDIR        *
  4202. *************************
  4203. makedirz    lea    parm2(a5),a4
  4204. .A    move.l    (a4)+,d1
  4205.     beq.s    .B
  4206.     bsr.s    mkdir
  4207.     bra.s    .A
  4208. .B    moveq    #RETURN_OK,d0
  4209.     rts
  4210.     
  4211. *MAKEDIR D1-> directory name
  4212. mkdir    jsr    _LVOCreateDir(a6)
  4213.     tst.l    d0
  4214.     beq    DOSerr
  4215.     move.l    d0,d1
  4216.     jsr    _LVOUnLock(a6)
  4217. *    moveq    #0,d0
  4218.     rts
  4219.  
  4220. *************************
  4221. *    PROMPT        *
  4222. *************************
  4223. promptz    move.l    parm2(a5),d0
  4224.     beq.s    .B
  4225.     bsr    parse_echo
  4226.     move.l    parm2(a5),a0
  4227.     lea    prompt_args(a5),a2
  4228.     lea    1(a2),a1
  4229.     moveq    #-1,d0
  4230. .A    addq.b    #1,d0
  4231.     move.b    (a0)+,(a1)+
  4232.     bne.s    .A
  4233. .C    move.b    d0,(a2)
  4234.     MOVEQ    #RETURN_OK,D0
  4235.     rts
  4236. .B    lea    prompt_args+1(a5),a1
  4237.     bsr    pr_stringlf
  4238.     moveq    #RETURN_OK,d0
  4239.     rts
  4240.     
  4241. **************    
  4242. compose_prompt
  4243.     lea    prompt_string(a5),a1
  4244.     move.l    a1,prompt_cr(a5)
  4245.     lea    farb3(pc),a0
  4246. .C    move.b    (a0)+,(a1)+    copy highlight colour
  4247.     bne.s    .C
  4248.     subq.l    #1,a1
  4249.     lea    prompt_args+1(a5),a0
  4250. cpro3    move.b    (a0)+,d0
  4251.     beq    composer3
  4252.     cmp.b    #$5c,d0 ;\
  4253.     bne.s    .A
  4254.     move.b    (a0)+,d0
  4255.     bra    composer2
  4256. .A    cmp.b    #'%',d0
  4257.     bne    composer2
  4258.     move.b    (a0)+,d0
  4259.     bset    #5,d0
  4260.     cmp.b    #'p',d0        check if %p
  4261.     bne.s    try_halfcd
  4262.     lea    CD_string+1(a5),a2
  4263. .B    move.b    (a2)+,(a1)+    copy cd_string to prompt_string
  4264.     bne.s    .B
  4265.     lea    -1(a1),a1
  4266.     bra    cpro3
  4267. try_halfcd
  4268.     cmp.b    #'s',d0        check if %s
  4269.     bne.s    try_line_num
  4270.     lea    CD_string+1(a5),a2
  4271.     move.l    a2,d1
  4272. .A    tst.b    (a2)+
  4273.     bne.s    .A
  4274.     subq.l    #2,a2
  4275.     bra.s    .D
  4276. .C    move.b    -(a2),d0
  4277. .D    cmp.l    a2,d1
  4278.     bhi.s    .E
  4279.     cmp.b    #"/",d0
  4280.     beq.s    .E
  4281.     cmp.b    #":",d0
  4282.     bne.s    .C
  4283. .E    addq.l    #1,a2
  4284. .B    move.b    (a2)+,(a1)+    copy cd_string to prompt_string
  4285.     bne.s    .B
  4286.     lea    -1(a1),a1
  4287.     bra    cpro3
  4288. try_line_num
  4289.     cmp.b    #'l',d0        check if %l
  4290.     bne.s    try_oldcmd
  4291.     move.l    count_line(a5),d0
  4292.     moveq    #0,d1
  4293.     move.l    a1,a2
  4294.     bsr    qdecpr        insert current line number
  4295.     move.l    a2,a1
  4296.     bra    cpro3
  4297. try_oldcmd
  4298.     cmp.b    #'c',d0        check if %c
  4299.     bne.s    try_task_num
  4300.     lea    shelline(a5),a2
  4301. .B    move.b    (a2)+,(a1)+
  4302.     bne.s    .B
  4303.     lea    -1(a1),a1
  4304.     bra    cpro3
  4305. try_task_num
  4306.     cmp.b    #'n',d0        check if %n
  4307.     bne.s    composer2
  4308.     move.l    thistask(a5),a2
  4309.     move.l    pr_TaskNum(a2),d0
  4310.     add.b    #$30,d0
  4311. composer2    move.b    d0,(a1)+
  4312.     cmp.b    #LF,d0
  4313.     bne.s    .A
  4314.     move.l    a1,prompt_cr(a5)
  4315. .A    bra    cpro3
  4316. composer3    lea    farb1(pc),a0
  4317. .A    move.b    (a0)+,(a1)+
  4318.     bne.s    .A
  4319.     rts
  4320.  
  4321.     
  4322. *FILL FIB WITH EXAMINE A0-> directory name ,D7=filelock on return
  4323. fibexam    move.l    a0,-(sp)
  4324.     moveq    #ACCESS_READ,d2
  4325.     move.l a0,d1
  4326.     jsr    _LVOLock(a6)
  4327.     move.l    d0,d7
  4328.     beq    DOSerr
  4329.     bsr    fibexam2
  4330.     move.l    (sp)+,a0
  4331.     rts
  4332. fibexam2
  4333.     move.l    d0,d1
  4334.     move.l    a5,d2
  4335.     jsr    _LVOExamine(a6)
  4336.     tst.l    d0
  4337.     beq    DOSerrUL
  4338.     rts
  4339.  
  4340. *****************
  4341. *    CD    *
  4342. *****************
  4343. cdz    tst.l    parm2(a5)
  4344.     beq    querycd
  4345.     move.l    parm2(a5),a0
  4346. chdir    * check and change directory, a0=dirname
  4347.     move.l    d7,-(sp)
  4348.     bsr    fibexam
  4349.     move.l    d7,d1
  4350.     move.l    (sp)+,d7
  4351.     tst.l    fib_DirEntryType(a5)    ;check entry OK
  4352.     bpl.s    .A
  4353.     jsr    _LVOUnLock(a6)
  4354.     move.l    #212,d0
  4355.     bra    pr_galactic
  4356. *CHANGE DIRECTORY d1:lock to new current directory
  4357. .A    move.l    d1,a0
  4358.     add.l    a0,a0
  4359.     add.l    a0,a0
  4360.     move.l    thistask(a5),a1
  4361.     move.l    fl_Task(a0),pr_FileSystemTask(a1)
  4362.     jsr    _LVOCurrentDir(a6)
  4363.     move.l    d0,d1
  4364.     jsr    _LVOUnLock(a6)    unlock the old directory
  4365.     lea    CD_string+1(a5),a0
  4366.     lea    CDbackstr(a5),a1
  4367. .B    move.b    (a0)+,(a1)+    remember old directory
  4368.     bne.s    .B
  4369.     bsr    eval_CD        update cd string
  4370.     moveq    #RETURN_OK,d0
  4371.     rts
  4372.     
  4373. querycd    bsr    eval_CD
  4374.     lea    CD_string+1(a5),a1
  4375.     bsr    pr_stringlf
  4376.     moveq    #RETURN_OK,d0
  4377.     rts
  4378.  
  4379.  
  4380. ** Evaluate entire name of current directory and put in CD_string
  4381. eval_CD    clr.b    CD_string+1(a5)
  4382.     lea    null(pc),a0
  4383.     move.l    a0,d1
  4384.     moveq    #ACCESS_READ,d2
  4385.     jsr    _LVOLock(a6)
  4386.     tst.l    d0
  4387.     beq.s    .A
  4388.     move.l    d0,a0
  4389.     add.l    a0,a0
  4390.     add.l    a0,a0
  4391.     move.l    fl_Key(a0),cd_block(a5)
  4392.     move.l    fl_Volume(a0),cd_volnode(a5)
  4393.     lea    CD_string+1(a5),a0
  4394.     bsr    eval_full_path
  4395.     jsr    _LVOUnLock(a6)
  4396. .A    moveq    #-1,d0
  4397.     lea    CD_string(a5),a0
  4398.     lea    1(a0),a1
  4399. .B    addq.b    #1,d0    calculate size of BSTR
  4400.     tst.b    (a1)+
  4401.     bne.s    .B
  4402.     move.b    d0,(a0)
  4403.     rts
  4404.     
  4405. ** evaluate entire name associated with lock in D0, store string in A0
  4406. ** Return D1 = last lock to unlock
  4407. ** Reg usage: d0,d1,d2,d3,a0,a1,a3 (must not use A2)
  4408. eval_full_path
  4409.     move.b    #"?",(a0)
  4410.     clr.b    1(a0)
  4411.     move.l    d0,d1
  4412.     beq.s    .C
  4413.     lsl.l    #2,d0
  4414.     move.l    d0,a1
  4415.     moveq    #ACCESS_READ,d0
  4416.     cmp.l    fl_Access(a1),d0    only eval read locks
  4417.     bne.s    .B
  4418. .C    cmp.w    #36,kickver(a5)
  4419.     blo.s    .A
  4420.     move.l    d1,a3
  4421.     move.l    a0,d2
  4422.     moveq    #78,d3
  4423.     jsr    _LVONameFromLock(a6)
  4424.     move.l    a3,d1
  4425. .B    rts
  4426. .A    lea    -88(sp),sp
  4427.     move.l    a0,4(sp)        save address of string
  4428.     move.l    d1,(sp)        save original lock on stack
  4429.     move.l    a5,d2
  4430.     jsr    _LVOExamine(a6)
  4431.     move.l    4(sp),a1
  4432.     lea    fib_FileName(a5),a0
  4433. evx1    move.b    (a0)+,(a1)+    COPY FILENAME TO deststring
  4434.     bne.s    evx1
  4435.     lea    -1(a1),a3
  4436. evcd2    move.l    (sp),d1        get lock
  4437.     jsr    _LVOParentDir(a6)
  4438.     tst.l    d0
  4439.     beq.s    root_found
  4440.     move.l    (sp),d1
  4441.     move.l    d0,(sp)
  4442.     jsr    _LVOUnLock(a6)    unlock last
  4443.     move.l    (sp),d1
  4444.     move.l    a5,d2
  4445.     jsr    _LVOExamine(a6)
  4446.     lea    fib_FileName(a5),a0
  4447.     lea    8(sp),a1
  4448. evx2    move.b    (a0)+,(a1)+    stackbuf = filename
  4449.     bne.s    evx2
  4450.     move.b    #'/',-1(a1)
  4451.     move.l    4(sp),a0
  4452. evx3    move.b    (a0)+,(a1)+    stackbuf = filename/CD_string
  4453.     bne.s    evx3
  4454.     move.l    4(sp),a1
  4455.     lea    8(sp),a0
  4456. evx4    move.b    (a0)+,d0
  4457.     move.b    d0,(a1)+
  4458.     cmp.b    #'/',d0
  4459.     bne.s    evx4
  4460.     lea    -1(a1),a3
  4461. evx5    move.b    (a0)+,(a1)+    dest string = stackbuf
  4462.     bne.s    evx5
  4463.     bra    evcd2
  4464. root_found
  4465.     move.l    (sp),d1
  4466.     tst.b    (a3)
  4467.     bne.s    root2
  4468.     clr.b    1(a3)
  4469. root2    move.b    #':',(a3)
  4470.     lea    88(sp),sp
  4471.     rts
  4472.  
  4473. *ADDPATH A0-> path  A1-> parameter  A2-> destination for string
  4474. ** eg. (A0)='df0:libs',0  (A1)='arp.library',0  (A2)='df0:libs/arp.library',0
  4475. addpath    movem.l a0-a2,-(sp)
  4476.     move.b (a0),d0
  4477.     beq.s addp4
  4478. addp1    move.b (a0)+,d0
  4479.     beq.s addp2
  4480.     move.b d0,(a2)+
  4481.     bra.s addp1
  4482. addp2    move.b -2(a0),d0
  4483.     cmp.b #':',d0
  4484.     beq.s addp4
  4485.     cmp.b #'/',d0
  4486.     beq.s addp4
  4487.     move.b #'/',(a2)+
  4488. addp4    move.l a1,a0
  4489.     move.l a2,a1
  4490.     bsr cp_string
  4491.     movem.l (sp)+,a0-a2
  4492.     rts
  4493.  
  4494.  
  4495. * Search Resident list for command    V2.0:Global resi's
  4496. * RETURN D0=seglist OR 0 if not found
  4497. *    A0=addr of node        D2=addr of Vorgänger
  4498. search_res    move.l    parm1(a5),a4
  4499. search_res2
  4500.     bsr    resi_hand
  4501.     beq.s    .D
  4502.     move.l    a0,d2
  4503. .A    lsl.l    #2,d0
  4504.     move.l    a4,a1            string
  4505.     move.l    d0,a2
  4506.     lea    resi_name(a2),a0    BSTR
  4507.     moveq    #0,d3
  4508.     move.b    (a0)+,d3
  4509.     subq.w    #1,d3
  4510. .B    move.b    (a0)+,d0
  4511.     move.b    (a1)+,d1
  4512.     cmp.b    dotchar(a5),d1
  4513.     bne.s    .F
  4514.     tst.b    (a1)
  4515.     beq.s    .C
  4516. .F    bsr    compD1D0locale
  4517.     dbne    d3,.B
  4518.     bne.s    .E    not equal
  4519.     tst.b    (a1)
  4520.     beq.s    .C    the (null-)END
  4521. .E    move.l    a2,d2
  4522.     move.l    resi_link(a2),d0    get link
  4523.     bne.s    .A
  4524. .D    moveq    #0,d0
  4525.     rts
  4526. .C    moveq    #-1,d1
  4527.     cmp.l    resi_usecount(a2),d1    is it a system-resi ?
  4528.     beq.s    .D
  4529.     move.l    resi_seglist(a2),d0    get seglist
  4530.     move.l    a2,a0
  4531.     rts
  4532.  
  4533.  
  4534. *Search paths for command
  4535. *Exit: d0=seglist, d4=PROGDIR:, branches if script file
  4536. spaths    move.l    parm1(a5),a4    A4=parm1
  4537. spaths2    moveq    #0,d4    jump-in for resident,do not load scripts with it!
  4538.     move.l    thistask(a5),a3
  4539.     lea    pr_CurrentDir(a3),a3    (A3)=ptr to current dir
  4540.     move.l    (a3),d3            d3=current dir at beginning
  4541.     move.l    d3,d4            d4=PROGDIR:
  4542.     bsr    lock_or_load
  4543.     tst.l    d0
  4544.     bmi.s    .C        not found
  4545.     bne    gotit        found & executable
  4546.     tst.b    forcediskflag(a5)
  4547.     bne.s    .C        do not change dir
  4548.     tst.l    fib_DirEntryType(a5)    is it a DIR ?
  4549.     bmi    s_flagset    no, exec script ?
  4550.     tst.l    parm2(a5)
  4551.     bne.s    .C        argument given: do not change dir
  4552.     addq.l    #4,sp        return from archie3
  4553.     move.l    a4,a0
  4554.     bra    chdir        change current dir
  4555.  
  4556. .C    move.l    a4,a0
  4557. .F    move.b    (a0)+,d0    are there path-specific chars in the name
  4558.     cmp.b    #"/",d0
  4559.     beq.s    no_more_paths
  4560.     cmp.b    #":",d0
  4561.     beq.s    no_more_paths
  4562.     tst.b    d0
  4563.     bne.s    .F
  4564.     moveq    #-1,d1
  4565.     bsr    changeWindowPtr        no requesters
  4566.     move.l    CLIptr(a5),a2
  4567.     lea    cli_CommandDir(a2),a2    A2=ptr to current path
  4568.  
  4569. .A    move.l    (a2),d0        search all paths
  4570.     beq.s    no_more_paths
  4571.     lsl.l    #2,d0
  4572.     move.l    d0,a2
  4573.     move.l    4(a2),d4    d4=PROGDIR:
  4574.     beq.s    .A
  4575.     move.l    d4,(a3)
  4576.     bsr    lock_or_load    disk access
  4577.     tst.l    d0
  4578.     bmi.s    .A
  4579.     bne.s    gotit
  4580.     tst.l    fib_DirEntryType(a5)    is it a DIR ?
  4581.     bpl.s    .A
  4582.     bra.s    s_flagset    exec script
  4583. no_more_paths
  4584.     moveq    #0,d0
  4585. gotit    move.l    d3,(a3)        restore current dir
  4586.     moveq    #0,d1        requesters on
  4587.     bra    changeWindowPtr
  4588.  
  4589. lock_or_load
  4590.     move.l    a4,d1
  4591.     moveq    #ACCESS_READ,d2
  4592.     jsr    _LVOLock(a6)
  4593.     move.l    d0,d7
  4594.     bne.s    .A
  4595.     moveq    #-1,d0        file not found
  4596.     rts
  4597. .A    bsr    fibexam2
  4598.     moveq    #0,d0
  4599.     tst.l    fib_DirEntryType(a5)
  4600.     bpl.s    .C
  4601.     move.l    fib_Protection(a5),d1
  4602.     btst    #6,d1    script-bit ?
  4603.     bne.s    .C
  4604.     btst    #1,d1    not-execute-bit ?
  4605.     bne.s    .C
  4606.     move.l    a4,d1
  4607.     jsr    _LVOLoadSeg(a6)
  4608. .C    move.l    d0,-(sp)
  4609.     move.l    d7,d1
  4610.     jsr    _LVOUnLock(a6)
  4611.     move.l    (sp)+,d0
  4612.     rts
  4613.  
  4614. s_flagset
  4615.     move.l    d3,(a3)        restore current dir
  4616.     moveq    #0,d1        requesters on
  4617.     bsr    changeWindowPtr
  4618.     addq.l    #4,sp    kill return addresses (archie3,spaths)
  4619.     move.l    fib_Protection(a5),d1
  4620.     btst    #6,d1
  4621.     beq.s    .A
  4622.     addq.l    #4,sp    kill return addresses (archie3,spaths)
  4623.     move.l    a4,a0    A4 pts to filename
  4624.     bsr    readfile
  4625.     move.l    d3,(a3)        restore current dir
  4626.     bra    xz3
  4627. .A    move.l    #305,d0
  4628.     tst.l    parm2(a5)    argument given: do not show file
  4629.     bne.s    .E
  4630.     cmp.l    d3,d4        PROGDIR=Current Dir ?
  4631. .E    bne    pr_DOSerr    NO: file not executable
  4632. ;show ascii or amigaguide text
  4633.     move.l    4.w,a6        YES: show it with Amigaguide
  4634.     lea    guidename(pc),a1
  4635.     jsr    _LVOOldOpenLibrary(a6)
  4636.     tst.l    d0
  4637.     beq.s    .C        opened amigaguide.library ?
  4638.     move.l    d0,a6
  4639.     moveq    #NewAmigaGuide_SIZEOF/4-1,d0
  4640. .D    clr.l    -(sp)
  4641.     dbra    d0,.D
  4642.     move.l    a4,nag_Name(sp)    filename into nag
  4643.     move.l    sp,a0        nag to a0
  4644.     sub.l    a1,a1        must be zero
  4645.     jsr    _LVOOpenAmigaGuideA(a6)    open guide
  4646.     tst.l    d0
  4647.     beq.s    .B        failed to open guide ?
  4648.     move.l    d0,a0
  4649.     jsr    _LVOCloseAmigaGuide(a6)    wait till user closes guide
  4650. .B    lea    NewAmigaGuide_SIZEOF(sp),sp
  4651.     move.l    a6,a1        Free library
  4652.     move.l    4.w,a6
  4653.     jsr    _LVOCloseLibrary(a6)
  4654. .C    move.l    dosbase(a5),a6
  4655.     rts
  4656.  
  4657.  
  4658. * ARCHIE 3 calls system0 to execute non internal commands
  4659. archie3    tst.l    parm1(a5)        exit if nothing typed
  4660.     beq    noarch31
  4661.     clr.b    resi_flag(a5)        =0 if resident
  4662.     bsr    search_res        search resident list first
  4663.     tst.l    d0
  4664.     bne.s    .A
  4665.     addq.b    #1,resi_flag(a5)    =1 if not resident
  4666.     bsr    spaths            load the command
  4667.     tst.l    d0
  4668.     beq    noarch32        could not load
  4669.     cmp.w    #36,kickver(a5)
  4670.     blo.s    .A
  4671.     move.l    thistask(a5),a3
  4672.     move.l    d4,pr_HomeDir(a3)    init PROGDIR:
  4673. .A    move.l    d0,temp1(a5)        save the segment
  4674.     bsr    raw_off
  4675.     bsr    save_mem_time
  4676.     lea    CLIbuf(a5),a0
  4677.     move.l    a0,-(sp)    push arg_args ptr.
  4678.     move.l    d0,-(sp)    push seglist
  4679.     move.l    parm1(a5),d0
  4680.     move.l    d0,-(sp)    push arg_name
  4681.     bsr    _System0    TAKES 3 PARMS(ARG_NAME,SEGLIST,ARGS)
  4682.     lea    12(sp),sp
  4683.     move.l    d0,-(sp)
  4684.     cmp.w    #36,kickver(a5)
  4685.     blo.s    .G
  4686.     move.l    thistask(a5),a3
  4687.     clr.l    pr_HomeDir(a3)        reset PROGDIR:
  4688. .G    jsr    _LVOIoErr(a6)
  4689.     move.l    d0,Result2(a5)
  4690.     btst    #FLcheck,Flags+3(a5)
  4691.     beq.s    .C
  4692.     bsr    show_status
  4693. .C    tst.b    resi_flag(a5)
  4694.     beq.s    .B
  4695.     move.l    better_Seglist(a5),d1
  4696.     jsr    _LVOUnLoadSeg(a6)
  4697. .B    bsr    raw_on
  4698.     move.l    (sp)+,d2    RESULT IN D2
  4699.     beq.s    .D
  4700.     btst    #FLerrors,Flags+3(a5)
  4701.     beq.s    .D
  4702.     move.l    Result2(a5),d0
  4703.     beq.s    .D
  4704.     bsr    pr_DOSerr    if result > 0 print error
  4705. .D    move.l    d2,d0    
  4706. noarch31    rts
  4707. noarch32
  4708.     moveq    #-121,d0        command not found
  4709.     bsr    pr_DOSerr
  4710.     moveq    #RETURN_BAD,d0        return d0 bad
  4711.     rts
  4712.  
  4713.  
  4714. *****    SYSTEM0 execute command from disk. From Sozobon C distribution.
  4715. * Copyright © 1988 by Ralph Babel.
  4716. *
  4717. * This piece of code may be used as part of any product as
  4718. * long as the source code for the complete program can be
  4719. * obtained free of charge (except for a small copying fee)
  4720. * and this copyright notice is left unchanged.
  4721. _System0
  4722.     movem.l    d2-d3/a2-a6,-(sp)    ;SAVED_REGS
  4723.     moveq    #NO_CLI,REG_Result      ;#-1,d3 ERROR - not a CLI task
  4724.     move.l    4.w,REG_SysBase    ;4,a6
  4725.     move.l    thistask(a5),REG_Process    ;a2
  4726.     move.l    pr_CLI(REG_Process),d0
  4727.     beq    quit0
  4728.  
  4729. * build local stack frame & save some values
  4730.     lsl.l    #2,d0
  4731.     move.l    d0,REG_CLI    ;a3
  4732.     move.l    sp,REG_PrevStack        ;a1 save old stack pointer
  4733.     move.l    sp,d0
  4734.     and.b    #$fc,d0 ;make SP longword-aligned for BPTRs
  4735.     move.l    d0,sp
  4736.     sub.l    #sf_SIZEOF,sp    ;stack-frame-struct
  4737.     move.l    REG_PrevStack,sf_PrevStack(sp)
  4738.     move.l    REG_Process,sf_Process(sp)
  4739.     move.l    REG_CLI,sf_CLI(sp)
  4740.     move.l  pr_ReturnAddr(REG_Process),sf_SaveReturnAddr(sp)
  4741.  
  4742. * allocate space for stack
  4743.     moveq    #NO_MEM,REG_Result    ;ERROR - no memory for STACK
  4744.     move.l    cli_DefaultStack(REG_CLI),d0    ;in longwords for "VEC"
  4745.     lsl.l    #2,d0
  4746.     move.l    d0,sf_PushSize(sp)
  4747.     addq.l    #4,d0    ;one additional longword
  4748.     move.l    d0,sf_StackSize(sp)
  4749.     moveq    #1,d1    ;intentionally NOT "MEMF_PUBLIC"!; V2.0 Why not ?
  4750.     callsys    AllocMem
  4751.     tst.l    d0
  4752.     beq    quit1
  4753.     move.l    d0,sf_StackBase(sp)    ;save result
  4754.  
  4755. * save old command pointer, build new BCPL command name
  4756.     move.l    cli_CommandName(REG_CLI),sf_SaveCommandName(sp)
  4757.     move.l    sf_PrevStack(sp),REG_PrevStack
  4758.     move.l    ARG_NAME(REG_PrevStack),a0 ;first parameter to "System0()"
  4759.     lea    sf_CommandName(sp),a1 ;BSTR
  4760.     move.w    #MAXBSTR-2,d0
  4761.     bsr    cpBSTR
  4762.     move.l    d0,cli_CommandName(REG_CLI)
  4763. * save contents of Current Input Stream
  4764.     move.l    pr_CIS(REG_Process),d0
  4765.     lsl.l    #2,d0
  4766.     move.l    d0,REG_CIS
  4767.     move.l    REG_CIS,sf_CIS(sp)
  4768.     move.l    fh_Buf(REG_CIS),sf_SCB_Buf(sp)
  4769.     move.l    fh_Pos(REG_CIS),sf_SCB_Pos(sp)
  4770.     move.l    fh_End(REG_CIS),sf_SCB_End(sp)
  4771. tst
  4772. * convert argument to LF-terminated string
  4773.     move.l    sf_PrevStack(sp),REG_PrevStack
  4774.     move.l    ARG_ARGS(REG_PrevStack),a0 ;third argument to "System0()"
  4775.     lea    sf_CommandArgs(sp),a1    ;first buffer location
  4776.     move.l    a1,d0
  4777.     lsr.l    #2,d0
  4778.     move.l    d0,fh_Buf(REG_CIS)
  4779.     move.w    #MAXBSTR-1,d0    ;leave some room for terminating LF
  4780.     bra.s    .D
  4781. .C    move.b    d1,(a1)+
  4782. .D    move.b    (a0)+,d1
  4783.     dbeq    d0,.C
  4784.     move.b    #LF,(a1)
  4785.     move.l    sf_PrevStack(sp),REG_PrevStack
  4786.     sub.l    ARG_ARGS(REG_PrevStack),a0    ;subtract first position
  4787.     move.l    a0,d0    ;do NOT subtract 1, LF need this byte
  4788. * setup start/end indices in Stream Control Block
  4789.     clr.l   fh_Pos(REG_CIS)
  4790.     move.l  d0,fh_End(REG_CIS)
  4791.  
  4792. * misc setup
  4793.     clr.l    pr_Result2(REG_Process)    ;clear secondary result
  4794.     move.l    a5,sf_Membase(sp)    ;save membase
  4795. ;    moveq    #0,d0
  4796. ;    moveq    #0,d1
  4797. ;    bset    #SIGBREAKB_CTRL_C,d1
  4798. ;    callsys    SetSignal    ;clear CTRL-C flag
  4799.  
  4800. * handle seglist and start address
  4801.     move.l    cli_Module(REG_CLI),sf_SaveModule(sp)
  4802.     move.l    sf_PrevStack(sp),REG_PrevStack
  4803.     move.l    ARG_SEGLIST(REG_PrevStack),d0 ;second argument to "System0()"
  4804.     move.l    d0,cli_Module(REG_CLI)
  4805.     lsl.l    #2,d0
  4806.     move.l    d0,a3
  4807. * setup processor registers & C-interface
  4808.     lea    sf_CommandArgs(sp),a0
  4809.     move.l    fh_End(REG_CIS),d0
  4810. * setup processor registers, BCPL-interface, stack & return address for "Exit()"
  4811.     move.l    sf_StackBase(sp),a1    ;BCPL stack, low end
  4812.     move.l    sf_PushSize(sp),d2
  4813.     lea    4(a1,d2.l),a4    ;must not destroy REG_Process!
  4814.     move.l    sp,-(a4)    ;previous stack frame
  4815.     move.l    d2,-(a4)    :stack size in bytes
  4816.     move.l    a4,pr_ReturnAddr(REG_Process)
  4817.     move.l    a4,sp
  4818.     move.l    dosbase(a5),a4    ;V2.0 small data
  4819.     movem.l    dl_A2(a4),a2/a5/a6
  4820.  
  4821. * now call the command at its entry point
  4822.     jsr    4(a3)    ;code starts one longword behind segment pointer
  4823.     move.l    d0,REG_Result    ;save return code
  4824.  
  4825. * get old stackframe & reload old register contents
  4826.     move.l    4(sp),sp    ;old stack frame
  4827.     move.l    sf_Membase(sp),a5
  4828.     move.l    sf_Process(sp),a0
  4829.     move.l    sf_SaveReturnAddr(sp),pr_ReturnAddr(a0)
  4830.     move.l    sf_CIS(sp),d0
  4831.     move.l    d0,a1
  4832.     lsr.l    #2,d0
  4833.     move.l    d0,pr_CIS(a0)    ;V2.0 restore CIS
  4834.     move.l    sf_CLI(sp),a0
  4835.     move.l    sf_SaveCommandName(sp),cli_CommandName(a0)
  4836. * Next line makes powerpacker programs deallocate memory properly
  4837.     move.l    cli_Module(a0),better_Seglist(a5)    ;V2.0 small data
  4838.     move.l    sf_SaveModule(sp),cli_Module(a0)
  4839. * restore original contents of Current Input Stream
  4840.     move.l    sf_CIS(sp),a0
  4841.     lea    sf_CommandArgs(sp),a1
  4842.     move.l    a1,d0
  4843.     lsr.l    #2,d0
  4844.     cmp.l    fh_Buf(a0),d0    ;still the same?
  4845.     bne.s    .E    ;no: don't restore
  4846.     move.l    sf_SCB_Buf(sp),fh_Buf(a0)
  4847. .E    move.l    sf_SCB_Pos(sp),fh_Pos(a0)
  4848.     tst.l    fh_End(a0)    ;end index set?
  4849.     beq.s    .F    ;no: don't restore
  4850.     move.l    sf_SCB_End(sp),fh_End(a0)
  4851.  
  4852. * free temporary stack
  4853. .F    move.l    4.w,REG_SysBase
  4854.     move.l    sf_StackBase(sp),a1
  4855.     move.l    sf_StackSize(sp),d0
  4856.     callsys    FreeMem
  4857.  
  4858. quit1    move.l    sf_PrevStack(sp),sp    ;UNLINK local variables
  4859. quit0    move.l    REG_Result,d0
  4860.     movem.l    (sp)+,d2-d3/a2-a6    ;SAVED_REGS
  4861. quitx    rts
  4862.  
  4863.  
  4864. *************************
  4865. *    HELP        *
  4866. *************************
  4867. helpz    bsr    rawh_off
  4868.     move.l    parm2(a5),d7
  4869.     bne    help_man
  4870.     lea    helptx1(pc),a1
  4871.     bsr    pr_stringlf
  4872.     lea    comtext(pc),a4
  4873.     lea    tempbuf(a5),a3
  4874. .D    moveq    #5,d3
  4875. .C    move.l    a3,a2
  4876.     tst.b    (a4)        
  4877.     beq    .E
  4878.     moveq    #12,d2
  4879. .B    subq.l    #1,d2
  4880.     move.b    (a4)+,(a2)+
  4881.     bne.s    .B
  4882.     tst.b    -(a2)    bump    back
  4883. .A    move.b    #$20,(a2)+
  4884.     dbra    d2,.A
  4885.     clr.b    (a2)
  4886.     move.l    a3,a1
  4887.     bsr    pr_string
  4888.     dbra    d3,.C
  4889.     bsr    pr_lf
  4890.     bra    .D
  4891. .E    bsr    pr_lf
  4892.     lea    helptx2(pc),a4
  4893.     lea    helptx3(pc),a0
  4894.     move.l    a0,d6
  4895.     bsr    pr_screen
  4896.     moveq    #RETURN_OK,D0
  4897.     rts
  4898.  
  4899. * print out part of manual, d7 points to topic
  4900. help_man lea    manadr(pc),a2    global variable
  4901.     move.l    4(a2),d1
  4902.     move.l    (a2),d0
  4903.     bne.s    .A
  4904.     lea    helpld(pc),a1
  4905.     bsr    pr_string
  4906.     bsr    pr_lf
  4907.     move.l    online_help(a5),a0
  4908.     bsr    readfile    load manual
  4909.     move.l    d0,(a2)        manadr
  4910.     move.l    d1,4(a2)    mansize
  4911. .A    move.l    d0,a3
  4912.     move.l    d1,d5
  4913.     add.l    a3,d5
  4914.     move.l    a3,a2
  4915.     move.l    d7,a1        type all ?
  4916.     moveq    #0,d4
  4917.     cmp.b    #"?",(a1)
  4918.     beq    make_screen    type all !
  4919. .B    move.l    d7,a1
  4920.     move.l    d5,a0
  4921.     addq.l    #1,a2
  4922.     bsr    searchSTR    search topic in manual
  4923.     cmp.b    #LF,d0
  4924.     bne.s    .C
  4925.     cmp.b    #"=",-6(a2)    there must be a lot of "=" before topic
  4926.     bne.s    .B
  4927.     cmp.b    #"=",-7(a2)    leave room for underlined sequence
  4928.     bne.s    .B
  4929.     cmp.b    #LF,-1(a2)
  4930.     beq.s    .F
  4931.     cmp.b    #"m",-1(a2)
  4932.     bne.s    .B
  4933. .F    move.l    a1,d4
  4934. .E    bsr    check_c        ctrl-c ?
  4935.     bne.s    .C
  4936. .D    cmp.l    d5,a1
  4937.     bhi.s    .C
  4938.     cmp.b    #LF,(a1)+    print lines separately
  4939.     bne.s    .D
  4940.     move.l    d4,d2
  4941.     move.l    a1,d3
  4942.     sub.l    d2,d3
  4943.     move.l    a1,d4
  4944.     move.l    outhandle(a5),d1
  4945.     jsr    _LVOWrite(a6)
  4946.     move.l    d4,a1
  4947.     cmp.b    #"=",-2(a1)    search next lot of "="
  4948.     bne.s    .E
  4949.     cmp.b    #"=",-3(a1)
  4950.     bne.s    .E
  4951.     bra.s    .B        another fitting topic ?
  4952. .C    moveq    #RETURN_OK,D0
  4953.     rts
  4954.  
  4955. giveman    movem.l    d0/d1/a0/a1,-(sp)    free manual-memory
  4956.     lea    manadr(pc),a0
  4957.     tst.l    (a0)
  4958.     beq.s    .A
  4959.     move.l    (a0),a1
  4960.     clr.l    (a0)
  4961.     move.l    4(a0),d0
  4962.     bsr    givemem
  4963. .A    movem.l    (sp)+,d0/d1/a0/a1
  4964.     rts
  4965.  
  4966.  
  4967. * PRINT A STRING BUT PUT A LINEFEED AFTER IT
  4968. pr_stringlf    bsr pr_string
  4969.         bra pr_lf
  4970.  
  4971. *****************    
  4972. *    PATH    *     Assign path or show it.
  4973. *****************
  4974. pathz    lea    parm2(a5),a3
  4975.     move.l    (a3),d0        see whether any parameters
  4976.     beq    ShowPaths
  4977.     move.l    CLIptr(a5),a4
  4978.     lea    cli_CommandDir(a4),a4
  4979.     move.l    d0,a0
  4980.     bsr    return_dash_option
  4981.     cmp.b    #"C",d0
  4982.     bne.s    .F
  4983.     bsr    DeletePaths    * remove all paths
  4984.     addq.l    #4,a3
  4985.  
  4986. .F    moveq    #-1,d3        reverse order
  4987. .G    addq.l    #1,d3
  4988.     tst.l    (a3)+
  4989.     bne.s    .G
  4990.     subq.l    #4,a3
  4991.     bra.s    .D
  4992. .C    move.l    -(a3),d1
  4993.     moveq    #ACCESS_READ,d2    * add as many paths as given
  4994.     jsr    _LVOLock(a6)    get a lock
  4995.     move.l    d0,d2
  4996.     beq    DOSerr
  4997.     bsr    CreatePath
  4998.     beq    resi_no_mem
  4999. .D    dbra    d3,.C
  5000.     moveq    #RETURN_OK,d0
  5001.     rts
  5002.  
  5003. DeletePaths    ;a4=cli_CommandDir, removes all paths
  5004.     move.l    a2,-(sp)
  5005.     move.l    a4,a2
  5006. .A    move.l    (a2),d0
  5007.     beq.s    .B
  5008.     lsl.l    #2,d0
  5009.     move.l    d0,a2
  5010.     move.l    4(a2),d1
  5011.     beq.s    .A
  5012.     jsr    _LVOUnLock(a6)    unlock all paths
  5013.     bra.s    .A
  5014. .B    move.l    (a4),d1
  5015.     beq.s    .E
  5016.     jsr    _LVOUnLoadSeg(a6)    free memory
  5017.     tst.l    d0
  5018.     beq    DOSerr
  5019.     clr.l    (a4)        set path ptr to nil
  5020. .E    move.l    (sp)+,a2
  5021.     rts
  5022.  
  5023. CreatePath    ;d2=Lock, a4=cli_CommandDir
  5024.     moveq    #12,d0
  5025.     moveq    #1,d1
  5026.     bsr    iwantmem    create seglist
  5027.     bsr    maybeDOSerr
  5028.     beq.s    .A
  5029.     move.l    d0,a0
  5030.     addq.l    #4,d0
  5031.     lsr.l    #2,d0
  5032.     moveq    #12,d1
  5033.     move.l    d1,(a0)        size of seglist
  5034.     move.l    (a4),4(a0)    link the new path
  5035.     move.l    d2,8(a0)    bptr to lock
  5036.     move.l    d0,(a4)        first in path-list
  5037. .A    rts
  5038.  
  5039. ShowPaths
  5040.     bsr    rawh_off
  5041.     move.l    #-152,d0
  5042.     bsr    GetMessage
  5043.     move.l    a0,a1
  5044.     bsr    pr_stringlf
  5045.     move.l    CLIptr(a5),a0
  5046.     lea    cli_CommandDir(a0),a2
  5047. .A    move.l    (a2),d0
  5048.     beq.s    .B
  5049.     lsl.l    #2,d0
  5050.     move.l    d0,a2
  5051.     move.l    4(a2),d1
  5052.     beq.s    .A
  5053.     jsr    _LVODupLock(a6)
  5054.     tst.l    d0
  5055.     beq.s    .A
  5056.     lea    tempbuf(a5),a0
  5057.     bsr    eval_full_path
  5058.     jsr    _LVOUnLock(a6)
  5059.     lea    tempbuf(a5),a1
  5060.     bsr    pr_stringlf
  5061.     bra.s    .A
  5062. .B    moveq    #RETURN_OK,d0
  5063.     rts
  5064.  
  5065. CopyPaths    ;copy paths from task in a0 to this task
  5066.     movem.l    d2-d3/a2-a4,-(sp)
  5067.     move.l    thistask(a5),a4
  5068.     move.l    pr_CLI(a4),d0
  5069.     beq.s    .D
  5070.     lsl.l    #2,d0
  5071.     move.l    d0,a4
  5072.     lea    cli_CommandDir(a4),a4
  5073.     move.l    pr_CLI(a0),d0
  5074.     beq.s    .D
  5075.     lsl.l    #2,d0
  5076.     move.l    d0,a0
  5077.     lea    cli_CommandDir(a0),a2
  5078.     lea    tempbuf(a5),a3
  5079.     moveq    #0,d3
  5080. .A    move.l    (a2),d0        * walk through all paths
  5081.     beq.s    .C
  5082.     lsl.l    #2,d0
  5083.     move.l    d0,a2
  5084.     move.l    4(a2),d1
  5085.     beq.s    .A
  5086.     move.l    d1,(a3)+
  5087.     addq.l    #1,d3
  5088.     bra.s    .A
  5089. .B    move.l    -(a3),d1
  5090.     jsr    _LVODupLock(a6)    copy lock
  5091.     move.l    d0,d2
  5092.     beq.s    .C
  5093.     bsr    CreatePath    add path
  5094. .C    dbra    d3,.B
  5095. .D    movem.l    (sp)+,d2-d3/a2-a4    return
  5096.     rts
  5097.  
  5098. *****************
  5099. *    INFO    *
  5100. *****************
  5101. infoz    bsr    rawh_off        ;V2.0 (fully new)
  5102.     lea    inform_tx(pc),a1
  5103.     bsr    pr_stringlf
  5104.     move.l    $22(a6),a0    ;rootnode
  5105.     move.l    $18(a0),a0    ;dosinfo
  5106.     add.l    a0,a0
  5107.     add.l    a0,a0
  5108.     move.l    4(a0),d6    ;devicelist
  5109. jajo    tst.l    d6
  5110.     bne    .B
  5111.     moveq    #RETURN_OK,d0
  5112.     rts
  5113.  
  5114. .B    lsl.l    #2,d6    ;BPTR
  5115.     move.l    d6,a4
  5116.     move.l    (a4),d6        ;next
  5117.     tst.l    4(a4)        ;type
  5118.     bne.s    jajo    ;was volume or assign
  5119.     tst.l    8(a4)        ;task
  5120.     beq.s    jajo    ;was non-disk-device
  5121. didev    move.l    $28(a4),a0    ;name
  5122.     add.l    a0,a0
  5123.     add.l    a0,a0
  5124.     moveq    #0,d0
  5125.     move.b    (a0)+,d0
  5126.     lea    tempbuf(a5),a3
  5127.     move.l    a3,a2
  5128.     bra.s    .D
  5129. .C    move.b    (a0)+,(a2)+
  5130. .D    dbra    d0,.C
  5131.     move.b    #":",(a2)+
  5132.     clr.b    (a2)
  5133.     move.l    8(a4),packettask(a5)    ;aptr task
  5134.     bsr    GetDiskInfo
  5135.     bsr    PKTerr
  5136.     bsr    do_forbid
  5137.     move.l    id_DiskType(a5),d1
  5138.     move.l    d1,d0
  5139.     clr.b    d0
  5140.     cmp.l    #"DOS"<<8,d0
  5141.     beq.s    itsDos        ;DOS-Disk
  5142.     move.l    #226,d0
  5143.     moveq    #-1,d2
  5144.     cmp.l    d1,d2
  5145.     beq.s    .F
  5146.     subq.l    #1,d0
  5147.     cmp.l    #"BAD"<<8,d1
  5148.     beq.s    .F
  5149.     cmp.l    #"NDOS",d1
  5150.     beq.s    .F
  5151.     lea    kickdisk(pc),a0
  5152.     cmp.l    #"KICK",d1
  5153.     beq.s    .G
  5154.     move.l    #213,d0
  5155. .F    bsr    GetMessage
  5156. .G    move.l    a0,-(sp)
  5157.     move.l    id_UnitNumber(a5),-(sp)
  5158.     move.l    a3,-(sp)
  5159.     bsr    do_permit
  5160.     lea    (sp),a1
  5161.     lea    inform2(pc),a0
  5162.     bsr    new_print
  5163.     lea    12(sp),sp
  5164.     bra    jajo
  5165.  
  5166. itsDos    move.l    id_VolumeNode(a5),a0    ;DOS-Disk
  5167.     add.l    a0,a0
  5168.     add.l    a0,a0
  5169.     move.l    $28(a0),a0        ;name    (hope, it is NULL-ending)
  5170.     add.l    a0,a0
  5171.     add.l    a0,a0
  5172.     addq.l    #1,a0
  5173.     move.l    a0,-(sp)
  5174.     move.l    id_NumSoftErrors(a5),-(sp)    ;SoftErrors
  5175.     move.l    id_DiskState(a5),d0
  5176.     lea    statro(pc),a0
  5177.     moveq    #80,d1
  5178.     cmp.l    d1,d0
  5179.     beq.s    .H
  5180.     lea    statrw(pc),a0
  5181.     moveq    #82,d1
  5182.     cmp.l    d1,d0
  5183.     beq.s    .H
  5184.     lea    statval(pc),a0
  5185.     moveq    #81,d1
  5186.     cmp.l    d1,d0
  5187.     beq.s    .H
  5188.     lea    statun(pc),a0
  5189. .H    move.l    a0,-(sp)        ;Status
  5190.     move.l    id_BytesPerBlock(a5),d1
  5191.     move.l    d1,-(sp)        ;BlockSize
  5192.     move.l    id_NumBlocks(a5),d0
  5193.     bsr    mult_32x32
  5194.     lsr.l    #8,d0
  5195.     lsr.l    #2,d0
  5196.     move.l    d0,d2
  5197.     move.l    id_NumBlocksUsed(a5),d0
  5198.     bsr    mult_32x32
  5199.     lsr.l    #8,d0
  5200.     lsr.l    #2,d0
  5201.     move.l    d2,d3
  5202.     sub.l    d0,d3
  5203.     moveq    #100,d1
  5204.     bsr    mult_32x32
  5205.     move.l    d2,d1
  5206.     beq.s    .D
  5207.     bsr    div_32    ;%
  5208. .D    exg    d0,d2
  5209.     move.l    d3,d1
  5210.     movem.l    d0-d2,-(sp)        ;Sizes
  5211.     lea    msd_tx(pc),a0    messydos ?
  5212.     move.l    $1c(a4),d0    dn_Startup
  5213.     moveq    #2,d1
  5214.     cmp.l    d1,d0
  5215.     bls.s    .A
  5216.     lsl.l    #2,d0
  5217.     move.l    d0,a1
  5218.     move.l    8(a1),d0    fssm_Environ
  5219.     beq.s    .A
  5220.     lsl.l    #2,d0
  5221.     move.l    d0,a1
  5222.     move.l    64(a1),d0    de_DosType
  5223.     cmp.l    #"MSD"<<8,d0    CrossDos ?
  5224.     beq.s    .C
  5225. .A    move.l    id_DiskType(a5),d0
  5226.     lea    quest_tx(pc),a0
  5227.     cmp.b    #5,d0
  5228.     bhi.s    .C    unknown
  5229.     ext.w    d0
  5230.     ext.l    d0
  5231.     lea    ofs_tx(pc),a0
  5232.     lsl.l    #2,d0
  5233.     add.l    d0,a0    d0*4+a0    access table
  5234. .C    move.l    a0,-(sp)        ;System
  5235.     move.l    id_UnitNumber(a5),-(sp)    ;Unit
  5236.     move.l    a3,-(sp)        ;Name
  5237.     bsr    do_permit
  5238.     lea    (sp),a1
  5239.     lea    inform(pc),a0
  5240.     bsr    new_print
  5241.     lea    40(sp),sp
  5242.     bra    jajo
  5243.  
  5244.  
  5245.  
  5246. *****************
  5247. *    ENDCLI    *    EXIT FROM ZSHELL TO CLI.
  5248. *****************    IF WE EXIT FROM SCRIPT THEN FREE SCRIPT MEMORY
  5249. endcliz    bsr    raw_off
  5250.     move.l    parm2(a5),a0
  5251.     bsr    return_dash_option
  5252.     moveq    #-1,d7
  5253.     cmp.b    #'C',d0
  5254.     bne.s    .A
  5255.     moveq    #0,d7
  5256. .A    bsr    kill_script
  5257.     addq.l    #4,sp    kill return address on stack
  5258.     rts
  5259.  
  5260. ** CHECK DIRECTORY DESCRIPTION IN (A0) AND CONVERTS INTO DIRNAME[0] AND PUTS
  5261. ** THE WILD CARD IN WILD_STRING. ALSO SETS WILD_FLAG
  5262. handle_wild_dirs
  5263.     clr.b    wild_flag(a5)
  5264.     btst    #FLwild,Flags+3(a5)
  5265.     beq.s    .B
  5266.     cmp.w    #37,kickver(a5)
  5267.     blo.s    .B
  5268.     movem.l    d2-d3/a0/a1,-(sp)
  5269.     lea    tempbuf(a5),a1
  5270.     move.l    a1,d1
  5271.     bsr    rempath
  5272.     lea    wild_string(a5),a0
  5273.     move.l    a0,d2
  5274.     moveq    #80,d3
  5275.     jsr    _LVOParsePatternNC(a6)    external matcher
  5276.     movem.l    (sp)+,d2-d3/a0/a1
  5277.     tst.l    d0
  5278.     bmi.s    .A
  5279.     beq.s    .A
  5280.     lea    tempbuf(a5),a1
  5281.     bra.s    .C
  5282. .B    lea    wild_string(a5),a1    internal matcher
  5283.     clr.b    (a1)
  5284.     bsr    check_wild
  5285.     tst.b    d0
  5286.     bne.s    .A
  5287. .C    bsr    split_wild
  5288.     move.b    #1,wild_flag(a5)
  5289. .A    rts    
  5290.  
  5291. ** SPLIT STRING(A0) INTO DIRECTORY PATH AND WILDCARD DESCRIPTION
  5292. ** NULL END THE PATH, AND MOVE THE WILDCARD TO (A1)
  5293. * eg. ram:c/*.info -> ram:c0 + *.info0    
  5294. split_wild
  5295.     movem.l    d0-d1/a0-a2,-(sp)
  5296.     move.l    a0,d1
  5297. sp_w2    move.l    a0,a2    a2=temp
  5298. sp_w3    move.b    (a0)+,d0
  5299.     beq.s    sp_w4
  5300.     cmp.b    #':',d0
  5301.     beq.s    sp_w2    A0= 1 after :
  5302.     cmp.b    #'/',d0
  5303.     beq.s    sp_w2
  5304.     bra.s    sp_w3
  5305. sp_w4    cmp.l    a2,d1
  5306.     beq.s    sp_mis
  5307.     cmp.b    #':',-1(a2)
  5308.     bne.s    sp_w5
  5309. sp_mis    move.l    a2,d1    SAVE POSITION
  5310. sp_w6    move.b    (a2)+,(a1)+
  5311.     bne.s    sp_w6
  5312.     move.l    d1,a2
  5313.     clr.b    (a2)
  5314.     movem.l    (sp)+,d0-d1/a0-a2
  5315.     rts
  5316. sp_w5    clr.b    -1(a2)
  5317. sp_w7    move.b    (a2)+,(a1)+
  5318.     bne.s    sp_w7
  5319.     movem.l    (sp)+,d0-d1/a0-a2
  5320.     rts
  5321.     
  5322. ** CHECK STRING(A0) IF IT CONTAINS WILDCARD SPECIFIC CHARS
  5323. ** RETURN D0=0 IF WILDS FOUND
  5324. check_wild    ;only used by handle_wild_dirs
  5325.     move.l    a0,-(sp)
  5326. chk_w3    move.b    (a0)+,d0
  5327.     beq.s    chk_w2
  5328.     cmp.b    #'*',d0
  5329.     beq.s    chk_w4
  5330.     cmp.b    #'~',d0    special not char
  5331.     beq.s    chk_w4
  5332.     cmp.b    #'[',d0
  5333.     beq.s    chk_w4
  5334.     cmp.b    #']',d0
  5335.     beq.s    chk_w4
  5336.     cmp.b    #'|',d0 or char
  5337.     beq.s    chk_w4
  5338.     cmp.b    #'?',d0
  5339.     bne.s    chk_w3
  5340. chk_w4    moveq    #0,d0
  5341.     move.l    (sp)+,a0
  5342.     rts
  5343. chk_w2    moveq    #1,d0
  5344.     move.l    (sp)+,a0
  5345.     rts
  5346.  
  5347. * NOTE this wildmatcher only handles cases where the wildcard has one * in it.
  5348. ** WILDCARD MATCHER. CHECK IF STRING(A0) MATCHES WILDCARD(A1)
  5349. ** RETURN D0=0 IF MATCH
  5350. wildmatch2
  5351.     btst    #FLwild,Flags+3(a5)
  5352.     beq.s    wildmatch
  5353.     cmp.w    #37,kickver(a5)
  5354.     blo.s    wildmatch
  5355.     movem.l    d2/a0/a1,-(sp)
  5356.     move.l    a0,d2
  5357.     move.l    a1,d1
  5358.     jsr    _LVOMatchPatternNC(a6)    external matcher
  5359.     movem.l    (sp)+,d2/a0/a1
  5360.     moveq    #0,d1
  5361.     tst.l    d0
  5362.     bne.s    .A
  5363.     addq.l    #1,d1
  5364. .A    move.l    d1,d0
  5365.     rts
  5366. wildmatch movem.l    d2/a2-a3,-(sp)
  5367.     move.b    (a1),d2
  5368.     cmp.b    #"~",d2        ;check if all is negated
  5369.     bne.s    .C
  5370.     addq.l    #1,a1
  5371. .C    move.l    a1,a2
  5372.     move.l    a0,a3
  5373. .A    move.b    (a2)+,d0
  5374.     beq.s    .B
  5375.     cmp.b    #"|",d0        ;or-symbol  V2.0
  5376.     bne.s    .A
  5377.     move.b    #0,-1(a2)    ;change wildcard to end
  5378.     bsr.s    wildermatch
  5379.     move.b    #"|",-1(a2)    ;restore
  5380.     tst.l    d0
  5381.     beq.s    gut
  5382.     lea    (a3),a0
  5383.     lea    (a2),a1
  5384.     bra.s    .A
  5385. .B    bsr.s    wildermatch
  5386. gut    cmp.b    #"~",d2
  5387.     bne.s    .D
  5388.     subq.l    #1,d0
  5389. .D    movem.l    (sp)+,d2/a2-a3
  5390.     rts
  5391.  
  5392. wildermatch
  5393.     cmp.b    #'~',(a1)        check for NOT specifier
  5394.     bne.s    wm_1
  5395.     move.b    (a1)+,d0
  5396.     bsr.s    wm_1
  5397.     subq.l    #1,d0    0 --> -1     1 --> 0
  5398.     rts
  5399.     
  5400. wm_1    move.b    (a0)+,d0
  5401.     beq    source_fin1
  5402.     move.b    (a1)+,d1
  5403.     cmp.b    #'*',d1
  5404.     beq.s    wild_run
  5405.     cmp.b    #'[',d1        handle character classes
  5406.     bne.s    .A
  5407. .B    move.b    (a1)+,d1
  5408.     beq.s    wild_fail
  5409.     cmp.b    #']',d1
  5410.     beq.s    wild_fail
  5411.     bsr    compD1D0nocase
  5412.     bne.s    .B
  5413. .C    move.b    (a1)+,d1
  5414.     beq.s    wild_fail
  5415.     cmp.b    #']',d1
  5416.     bne.s    .C
  5417.     bra.s    wm_1
  5418. .A    cmp.b    #'?',d1
  5419.     beq.s    wm_1
  5420.     bsr    compD1D0nocase
  5421.     beq.s    wm_1
  5422.     
  5423. wild_fail    moveq    #1,d0
  5424.     rts
  5425. wild_run    
  5426. wr_3    tst.b    (a0)+    GOTO END OF STRING
  5427.     bne.s    wr_3
  5428. wr_4    tst.b    (a1)+    GOTO END OF WILDCARD
  5429.     bne.s    wr_4
  5430. wr_5    move.b    -(a1),d0    get tail of wildcard (1st should be null)
  5431.     move.b    -(a0),d1
  5432.     cmp.b    #'*',d0
  5433.     beq.s    source_fin2
  5434.     cmp.b    #']',d0        handle class [xyz]
  5435.     bne.s    .A
  5436. .B    move.b    -(a1),d0
  5437.     cmp.b    #'*',d0
  5438.     beq.s    wild_fail
  5439.     cmp.b    #'[',d0
  5440.     beq.s    wild_fail
  5441.     bsr    compD1D0nocase
  5442.     bne.s    .B
  5443. .C    move.b    -(a1),d0
  5444.     beq.s    wild_fail    should never happen but should leave in
  5445.     cmp.b    #'[',d0
  5446.     bne.s    .C
  5447.     bra.s    wr_5
  5448. .A    cmp.b    #'?',d0
  5449.     beq.s    wr_5
  5450.     bsr    compD1D0nocase
  5451.     beq.s    wr_5
  5452.     bra.s    wild_fail
  5453. source_fin1
  5454.     tst.b    (a1)
  5455.     beq.s    source_fin2
  5456.     cmp.b    #'*',(a1)
  5457.     bne.s    wild_fail
  5458. source_fin2
  5459.     moveq    #0,d0
  5460.     rts
  5461.  
  5462. compD1D0locale
  5463.     tst.l    utilbase(a5)
  5464.     beq.s    compD1D0nocase
  5465.     movem.l    d2/a0/a1/a6,-(sp)
  5466.     move.l    utilbase(a5),a6
  5467.     move.b    d1,d2
  5468.     jsr    _LVOToUpper(a6)
  5469.     exg    d0,d2
  5470.     jsr    _LVOToUpper(a6)
  5471.     move.b    d0,d1
  5472.     move.b    d2,d0
  5473.     movem.l    (sp)+,d2/a0/a1/a6
  5474.     cmp.b    d1,d0
  5475.     rts
  5476.  
  5477. compD1D0nocase    ;lowercase d0 and d1 then compare them
  5478.     cmp.b    #'Z',d1
  5479.     bhi.s    D1_OK
  5480.     cmp.b    #'A',d1
  5481.     blo.s    D1_OK
  5482.     add.b    #$20,d1
  5483. D1_OK    cmp.b    #'Z',d0
  5484.     bhi.s    D0_OK
  5485.     cmp.b    #'A',d0
  5486.     blo.s    D0_OK
  5487.     add.b    #$20,d0
  5488. D0_OK    cmp.b    d1,d0
  5489.     rts
  5490.     
  5491. fibexnx    move.l    d7,d1
  5492.     move.l    a5,d2
  5493.     jsr    _LVOExNext(a6)
  5494.     rts
  5495.  
  5496. *********************************
  5497. *    DIRECTORY LISTER    *
  5498. *********************************
  5499. fname    equ    40    for sorting
  5500.  
  5501. dirz    clr.l    temp2(a5)        WIDE DIR, 2 columns
  5502.     bset    #31,temp2(a5)        bit 31=wide flag
  5503.     bra.s    directory
  5504.  
  5505. listz    clr.l    temp2(a5)        NARROW DIR, clear wide flag
  5506.     bset    #29,temp2(a5)        bit 29=verbose flag
  5507.     bset    #28,temp2(a5)        bit 28=comment flag
  5508. directory        ;V2.0:many things better (sort!)
  5509.     bsr    check_q_r
  5510. directory2
  5511.     lea    parm2(a5),a2
  5512.     bsr    rawh_off
  5513.     move.l    (a2),d1
  5514.     bne.s    .A
  5515.     lea    null(pc),a0
  5516.     move.l    a0,d1
  5517.     bra.s    .B
  5518.  
  5519. .A    move.l    (a2)+,d1    list all parms
  5520.     beq.s    .C
  5521. .B    move.l    a2,-(sp)
  5522.     move.l    d1,a2
  5523.     bsr    DirLister
  5524.     move.l    (sp)+,a2
  5525.     tst.l    d0
  5526.     bne.s    .E
  5527.     tst.b    break_flag(a5)
  5528.     beq.s    .A
  5529. .C    moveq    #RETURN_OK,d0
  5530. .E    rts
  5531.  
  5532. DirLister    ;wants dirname or filename in a2
  5533. *temp2-bits:    31:wide dir: DIR
  5534. *        30:quick, nosort: (all)
  5535. *        29:verbose list: LIST
  5536. *        28:comment: LIST
  5537. *        27:footer: (auto)
  5538. *        26:delete file: DELETE,MOVE
  5539. *        25:not process file: DELETE,COPY,MOVE
  5540. *        24:protect: PROTECT
  5541. *        23:copy: COPY,MOVE
  5542. *        22:move: MOVE
  5543. *        21:rename: MOVE
  5544. *        20:join: JOIN
  5545. *        19:split: SPLIT
  5546.     clr.l    temp1(a5)            init total size
  5547.     and.l    #$fff80000,temp2(a5)
  5548.     clr.l    temp3(a5)
  5549.     clr.l    temp4(a5)
  5550.     bset    #21,temp2+1(a5)
  5551.     btst    #31,temp2(a5)
  5552.     beq.s    .A
  5553.     bset    #0,temp2+3(a5)
  5554. .A    btst    #30,temp2(a5)
  5555.     beq.s    .B
  5556.     bclr    #28,temp2(a5)
  5557. .B    clr.w    indent_count(a5)
  5558.     move.l    a2,a0
  5559.     bsr    handle_wild_dirs
  5560.     lea    tempbuf(a5),a4
  5561. .C    move.b    (a2)+,(a4)+
  5562.     bne.s    .C
  5563.     bsr    pr_dir            -> print the dir
  5564.  
  5565. pr_size    movem.l    d0-d3,-(sp)        end of dirlister
  5566.     move.l    temp2(a5),d0        are we printing wide
  5567.     bpl.s    .B
  5568.     btst    #0,d0
  5569.     bne.s    .B
  5570.     bsr    pr_lf            print missing lf
  5571. .B    lea    (sp),a1
  5572.     lea    totsize(pc),a0
  5573.     btst    #27,temp2(a5)
  5574.     beq.s    .A
  5575.     bsr    new_print        print footer
  5576. .A    lea    16(sp),sp
  5577.     btst    #26,temp2(a5)        delete flag ?
  5578.     beq.s    .C
  5579.     tst.b    recurs_flag(a5)        recursiv, but no wildcard
  5580.     beq.s    .C
  5581.     tst.b    wild_flag(a5)
  5582.     bne.s    .C
  5583.     lea    tempbuf(a5),a0
  5584.     bsr    fibexam
  5585.     move.l    d7,d1
  5586.     jsr    _LVOUnLock(a6)
  5587.     bsr    SingleFile        delete parent dir
  5588. .C    moveq    #RETURN_OK,d0
  5589.     rts
  5590.  
  5591. pr_dir    bset    #27,temp2(a5)
  5592.     bclr    #25,temp2(a5)
  5593.     lea    tempbuf(a5),a0
  5594.     bsr    fibexam
  5595.     bsr    fixsoftlink
  5596.     tst.b    recurs_flag(a5)
  5597.     bne.s    .B
  5598.     btst    #24,temp2(a5)        protect flag ?
  5599.     bne.s    .D
  5600.     btst    #26,temp2(a5)        delete flag ?
  5601.     beq.s    .B
  5602. .D    tst.b    wild_flag(a5)
  5603.     beq.s    .C
  5604. .B    tst.l    fib_DirEntryType(a5)    check entry OK
  5605.     bpl.s    prd20            print whole Directory
  5606.  
  5607. .C    bsr    check_c
  5608.     bne    unlock
  5609.     move.l    d7,d1
  5610.     jsr    _LVOUnLock(a6)        unlock file
  5611. SingleFile
  5612.     lea    tempbuf(a5),a0        process a single file/dir
  5613.     move.l    a0,a1
  5614.     tst.b    (a1)
  5615.     beq.s    .B
  5616. .A    tst.b    (a1)+
  5617.     bne.s    .A
  5618.     cmp.b    #"/",-2(a1)        make sure it does not end in /
  5619.     bne.s    .B
  5620.     clr.b    -2(a1)
  5621. .B    lea    temp2buf(a5),a1
  5622.     bsr    split_wild        separate path and filename
  5623.     lea    tempbuf(a5),a0
  5624.     move.l    a0,d1            get a lock on the dir
  5625.     moveq    #ACCESS_READ,d2
  5626.     jsr    _LVOLock(a6)
  5627.     move.l    d0,d7
  5628.     bsr    pr_it            print single file/dir
  5629.     bclr    #27,temp2(a5)        do not print footer
  5630.     bra    unlock            make sure to unlock
  5631.  
  5632. prd20    tst.w    indent_count(a5)    was a dir
  5633.     bne.s    .A
  5634.     move.l    d7,d1
  5635.     jsr    _LVOUnLock(a6)
  5636.     lea    tempbuf(a5),a0
  5637.     move.l    a0,d1
  5638.     moveq    #ACCESS_READ,d2
  5639.     jsr    _LVOLock(a6)
  5640.     lea    temp2buf(a5),a0        get full dir name for later
  5641.     clr.b    (a0)
  5642.     tst.l    d0
  5643.     beq    DOSerr
  5644.     bsr    eval_full_path
  5645.     jsr    _LVOUnLock(a6)
  5646.     lea    dirof(pc),a1
  5647.     bsr    pr_string
  5648.     lea    temp2buf(a5),a1
  5649.     bsr    pr_stringlf        print directory's name
  5650.     lea    tempbuf(a5),a0
  5651.     bsr    fibexam
  5652.  
  5653. .A    sub.l    a3,a3    ;clr a3
  5654. prd2
  5655.     bsr    check_c        CTRL-C pressed ?
  5656.     bne    unlk
  5657.     bsr    fibexnx
  5658.     tst.l    d0
  5659.     beq    unlk        ;sort ?
  5660.     bsr    fixsoftlink
  5661.     move.l    temp2(a5),d0
  5662.     btst    #31,d0
  5663.     beq.s    .C
  5664.     move.l    fib_Protection(a5),d0
  5665.     btst    #7,d0
  5666.     bne.s    prd2    hide if hide flag is set in wide dir lister
  5667.     lea    FNCignore(a5),a1        hide ctrl-ignore
  5668.     tst.b    (a1)
  5669.     beq.s    .C
  5670.     lea    fib_FileName(a5),a0
  5671.     bsr    wildmatch2        wildcheck
  5672.     tst.b    d0
  5673.     beq.s    prd2
  5674. .C    tst.b    wild_flag(a5)
  5675.     beq.s    dozel
  5676.     tst.b    recurs_flag(a5)
  5677.     beq.s    .A
  5678.     tst.l    fib_DirEntryType(a5)
  5679.     bpl.s    dozel
  5680. .A    lea    fib_FileName(a5),a0
  5681.     lea    wild_string(a5),a1
  5682.     bsr    wildmatch2        wildcheck (can be external)
  5683.     tst.b    d0
  5684.     bne.s    prd2
  5685. dozel    btst    #30,temp2(a5)
  5686.     beq.s    collect            not quick
  5687.     btst    #26,temp2(a5)
  5688.     bne.s    collect            delete
  5689.     bsr    zelma
  5690.     bra.s    prd2
  5691.  
  5692. collect moveq    #fname,d0        collect files to sort  V2.0
  5693.     lea    fib_FileName(a5),a0
  5694.     lea    (a0),a2
  5695. .A    addq.l    #1,d0
  5696.     tst.b    (a0)+
  5697.     bne.s    .A
  5698.     lea    fib_Comment(a5),a0
  5699. .B    addq.l    #1,d0
  5700.     tst.b    (a0)+
  5701.     bne.s    .B
  5702.     moveq    #1,d1
  5703.     bsr    iwantmem
  5704.     bsr    maybeDOSerr
  5705.     beq    unlock
  5706.     move.l    d0,a0
  5707.     move.l    a3,(a0)+
  5708.     lea    -4(a0),a3
  5709.     lea    fib_DiskKey(a5),a1    ;store fib in mem
  5710.     move.l    (a1)+,(a0)+
  5711.     move.l    (a1)+,(a0)+
  5712.     lea    fib_Protection(a5),a1
  5713.     moveq    #6,d1
  5714. .C    move.l    (a1)+,(a0)+
  5715.     dbra    d1,.C
  5716. .D    move.b    (a2)+,(a0)+    ;name
  5717.     bne.s    .D
  5718. .E    move.b    (a1)+,(a0)+    ;comment
  5719.     bne.s    .E
  5720.     bra    prd2
  5721.  
  5722. unlk    btst    #26,temp2(a5)
  5723.     bne.s    .A        delete
  5724.     btst    #30,temp2(a5)
  5725.     bne    unlock        quick
  5726. .A    move.l    a3,d0    
  5727.     beq    unlock        no files
  5728. ;    tst.b    break_flag(a5)
  5729. ;    bne.s    nextfi        CTRL-C pressed
  5730.  
  5731.     movem.l    a4-a6,-(sp)
  5732.     btst    #30,temp2(a5)
  5733.     bne.s    snull        quick
  5734.     move.l    utilbase(a5),d2    localized-flag and libbase
  5735.     lea    (a3),a0        ;INSERTION SORT  V2.0   (ooohuuooo)
  5736. aussort    lea    (a3),a1
  5737.     move.l    (a0),a2    ;remove (a0->) a2
  5738.     move.l    a2,d0
  5739.     beq.s    snull    ;end of list
  5740.     move.l    (a2),(a0)
  5741.     bsr    strcmp    ;compare a1 and a2
  5742.     bne.s    insort    ;insert a2 (old place)
  5743.     move.l    a2,a3    ;a2->start
  5744.     move.l    a1,(a2)    ;a1=old start
  5745.     bra.s    aussort    ;next
  5746. insort    move.l    a1,a4    ;reminder
  5747.     move.l    (a1),a1    ;next a1
  5748.     cmp.l    a0,a4
  5749.     beq.s    inold
  5750. shno    bsr    strcmp    ;compare a1 and a2
  5751.     bne.s    insort    ;go on
  5752.     move.l    a2,(a4)    ;insert a2
  5753.     move.l    a1,(a2)    ;a4->a2->a1
  5754.     bra.s    aussort
  5755. inold    move.l    (a0),(a2) ;a2 back at old place
  5756.     move.l    a2,(a0)    ;a0->a2->next
  5757.     move.l    a2,a0    ;next a0
  5758.     bra.s    aussort
  5759. snull    movem.l    (sp)+,a4-a6    ;FINISHED !!!
  5760.  
  5761.     tst.l    temp2(a5)    for normal DIR
  5762.     bpl.s    nextfi
  5763.     tst.b    recurs_flag(a5)
  5764.     bne.s    nextfi
  5765.     moveq    #1,d0        prepare for printing in 2 columns
  5766.     move.l    a3,d1
  5767. .A    addq.l    #1,d0
  5768.     move.l    d1,a0
  5769.     move.l    (a0),d1
  5770.     bne.s    .A        count number of entries (d0)
  5771.     lsr.l    #1,d0        divide by two
  5772.     move.l    a3,a2
  5773.     bra.s    .B
  5774. .C    move.l    a2,a0
  5775.     move.l    (a2),a2
  5776. .B    dbra    d0,.C        find the middle    (a2 ,precedor in a0)
  5777.     clr.l    (a0)
  5778.  
  5779. nextfi    lea    4(a3),a1    print all files
  5780.     lea    fib_DiskKey(a5),a0    ;restore fib from mem
  5781.     move.l    (a1)+,(a0)+
  5782.     move.l    (a1)+,(a0)+
  5783.     lea    fib_Protection(a5),a0
  5784.     moveq    #6,d1
  5785. .F    move.l    (a1)+,(a0)+
  5786.     dbra    d1,.F
  5787.     moveq    #fname,d0
  5788.     lea    fib_FileName(a5),a0
  5789. .H    addq.l    #1,d0
  5790.     move.b    (a1)+,(a0)+    ;name
  5791.     bne.s    .H
  5792.     lea    fib_Comment(a5),a0
  5793. .B    addq.l    #1,d0
  5794.     move.b    (a1)+,(a0)+    ;comment
  5795.     bne.s    .B
  5796.     movem.l    d0/a2/a3,-(sp)
  5797.     tst.b    break_flag(a5)
  5798.     bne.s    .C        CTRL-C pressed
  5799.     bsr    check_c
  5800.     bne.s    .C
  5801.     bsr    zelma
  5802. .C    movem.l    (sp)+,d0/a2/a3
  5803.     move.l    (a3),d2
  5804.     lea    (a3),a1
  5805.     bsr    givemem
  5806.     move.l    d2,a3
  5807.     tst.l    temp2(a5)
  5808.     bpl.s    .A
  5809.     tst.b    recurs_flag(a5)
  5810.     bne.s    .A
  5811.     move.l    a2,a0        swap lower and upper list
  5812.     move.l    a3,a2
  5813.     move.l    a0,a3
  5814. .A    move.l    a3,d0        tst.l    a3
  5815.     bne    nextfi
  5816.  
  5817. unlock    move.l    d7,d1
  5818.     jsr    _LVOUnLock(a6)
  5819.     move.l    temp1(a5),d0    ;total size
  5820.     move.l    temp4(a5),d1
  5821.     move.l    temp2(a5),d2    ;No. of files and dirs
  5822.     btst    #31,d2
  5823.     beq.s    .A
  5824.     subq.l    #1,d2
  5825. .A    and.l    #$0007ffff,d2    ;1.000.000 files max. should be enough
  5826.     move.l    temp3(a5),d3    ;No. of dirs
  5827.     sub.l    d3,d2
  5828.     rts
  5829.  
  5830. strcmp    move.l    8(a1),d0
  5831.     move.l    8(a2),d1
  5832.     bmi.s    .A
  5833.     tst.l    d0    a2 is dir
  5834.     bpl.s    .B    a1 is dir too
  5835.     bra.s    donoth    a2:dir    a1:file
  5836. .A    tst.l    d0    a2 is file
  5837.     bpl.s    inseit    a2:file    a1:dir
  5838. .B    lea    fname(a1),a5    a1 is file too
  5839.     lea    fname(a2),a6
  5840. stcmp    tst.l    d2
  5841.     bne.s    lstcmp
  5842.     move.b    (a5)+,d1    compare strings in a3 and a4
  5843.     beq.s    donoth
  5844.     move.b    (a6)+,d0
  5845.     beq.s    inseit
  5846.     bsr    compD1D0nocase
  5847.     beq.s    stcmp
  5848.     bhi.s    donoth
  5849. inseit    moveq    #0,d0        insert it !
  5850.     rts
  5851. donoth    moveq    #1,d0        do nothing !
  5852.     rts
  5853.  
  5854. lstcmp    movem.l    a0/a1/a6,-(sp)    localized string-compare
  5855.     move.l    a5,a0
  5856.     move.l    a6,a1
  5857.     move.l    d2,a6
  5858.     jsr    _LVOStricmp(a6)
  5859.     tst.l    d0
  5860.     bmi.s    .A
  5861.     moveq    #0,d0
  5862. .A    movem.l    (sp)+,a0/a1/a6
  5863.     rts
  5864.  
  5865. zelma    tst.l    fib_DirEntryType(a5)
  5866.     bpl.s    .C
  5867.     bsr    pr_it        print file
  5868.     rts
  5869. .C    tst.b    recurs_flag(a5)
  5870.     bne.s    .B
  5871.     bsr    pr_it        print dir
  5872. .A    rts
  5873. .B    bset    #25,temp2(a5)    do not process this dir
  5874.     bsr    pr_it        print dir recursive
  5875.     bclr    #25,temp2(a5)
  5876.     move.w    temp2(a5),d0
  5877.     and.w    #%0000010010010000,d0    copy,delete or join flag
  5878.     beq.s    .D        no
  5879.     btst    #23,temp2+1(a5)    copy ?
  5880.     beq.s    .E
  5881.     move.l    temp5(a5),d1    yes:create new dir
  5882.     bsr    CurrentDir
  5883.     move.l    d0,d3
  5884.     lea    fib_FileName(a5),a2    copy: create dir
  5885.     move.l    a2,d1
  5886.     jsr    _LVOCreateDir(a6)
  5887.     move.l    d0,d2
  5888.     bne.s    .F
  5889. .G    jsr    _LVOIoErr(a6)
  5890.     cmp.l    #203,d0
  5891.     beq.s    .H
  5892.     move.l    d0,d2
  5893.     bsr    pr_lf
  5894.     move.l    d3,d1
  5895.     bsr    CurrentDir
  5896.     move.l    d2,d0
  5897.     bsr    pr_DOSerr
  5898.     rts
  5899. .F    move.l    d2,d1        unlock new dir, because is exclusive
  5900.     jsr    _LVOUnLock(a6)
  5901. .H    move.l    a2,d1
  5902.     moveq    #ACCESS_READ,d2
  5903.     jsr    _LVOLock(a6)
  5904.     move.l    d0,d2
  5905.     beq.s    .G
  5906.     move.l    d3,d1
  5907.     bsr    CurrentDir
  5908.     move.l    temp5(a5),d1    unlock old in temp5
  5909.     jsr    _LVOUnLock(a6)
  5910.     move.l    d2,temp5(a5)
  5911.     lea    makedirOK(pc),a1
  5912.     bsr    pr_string
  5913.     bsr    AdjustPath
  5914.     bra.s    .D
  5915. .E    bsr    pr_lf        no copy: just print lf
  5916.  
  5917. .D    moveq    #120,d0    ;(24bytes per recurs + subs + move-path)
  5918.     bsr    stacktest
  5919.     bne    .A
  5920.     move.l    fib_DiskKey(a5),d0
  5921.     movem.l    d0/d7/a4,-(sp)
  5922.     lea    fib_FileName(a5),a0
  5923.     subq.l    #1,a4
  5924.     lea    tempbuf(a5),a1
  5925.     cmp.l    a1,a4
  5926.     beq.s    jo
  5927.     cmp.b    #":",-1(a4)
  5928.     beq.s    jo
  5929.     cmp.b    #"/",-1(a4)
  5930.     beq.s    jo
  5931.     move.b    #"/",(a4)+
  5932. jo    move.b    (a0)+,(a4)+        ;addpath
  5933.     bne.s    jo
  5934.     addq.w    #2,indent_count(a5)
  5935. jojo    bsr    pr_dir            RECURSION    V2.0
  5936.     subq.w    #2,indent_count(a5)
  5937.     movem.l    (sp)+,d0/d7/a4
  5938.     move.l    d0,fib_DiskKey(a5)    ;restore fib
  5939.     lea    -1(a4),a0
  5940.     cmp.b    #"/",(a0)
  5941.     bne.s    .D
  5942.     clr.b    (a0)
  5943.     addq.l    #1,a0
  5944. .D    lea    (a0),a2
  5945.     lea    fib_FileName(a5),a1
  5946. je    move.b    (a0)+,(a1)+
  5947.     bne.s    je
  5948.     clr.b    (a2)
  5949.     moveq    #2,d0
  5950.     move.l    d0,fib_DirEntryType(a5)
  5951.     move.l    d0,fib_EntryType(a5)
  5952.     moveq    #0,d0
  5953.     move.l    d0,fib_Size(a5)
  5954.     move.l    d0,fib_NumBlocks(a5)
  5955.     btst    #23,temp2+1(a5)    copy ?
  5956.     beq.s    .B
  5957.     move.l    temp5(a5),d2    COPY
  5958.     move.l    d2,d1
  5959.     jsr    _LVOParentDir(a6)
  5960.     move.l    d0,temp5(a5)
  5961.     move.l    d2,d1
  5962.     jsr    _LVOUnLock(a6)
  5963.     bsr    AdjustPath
  5964. .B    btst    #26,temp2(a5)    delete ?
  5965.     beq.s    .A
  5966.     move.l    temp2(a5),-(sp)
  5967.     bclr    #22,temp2+1(a5)    move off
  5968.     bsr    pr_it        now delete this dir
  5969.     move.l    (sp)+,temp2(a5)
  5970. .A    rts
  5971.  
  5972. AdjustPath
  5973.     btst    #22,temp2+1(a5)
  5974.     beq.s    .D
  5975.     btst    #21,temp2+1(a5)
  5976.     beq.s    .D
  5977.     move.l    temp5(a5),d1
  5978.     jsr    _LVODupLock(a6)
  5979.     tst.l    d0
  5980.     beq    DOSerr
  5981.     move.l    temp7(a5),a0
  5982.     bsr    eval_full_path
  5983.     jsr    _LVOUnLock(a6)
  5984. .D    rts
  5985.  
  5986. pr_it    bsr    num_spc            print file or dir
  5987.     tst.l    fib_DirEntryType(a5)    check whether is dir
  5988.     bmi.s    .A            if plus,is directory
  5989.     move.l    temp2(a5),d0        check for "DIR -R"
  5990.     bpl.s    .G
  5991.     tst.b    recurs_flag(a5)
  5992.     beq.s    .G
  5993.     btst    #0,d0
  5994.     bne.s    .H
  5995.     subq.l    #1,temp2(a5)
  5996.     bsr    pr_lf            for DIR -R directories
  5997. .H    addq.l    #1,temp2(a5)
  5998. .G    lea    farb3(pc),a1        change foregnd colour
  5999.     bsr    addstring
  6000.     addq.l    #1,temp3(a5)        one dir more
  6001. .A    lea    fib_FileName(a5),a1
  6002.     move.l    a1,a0
  6003.     moveq    #-1,d2
  6004.     add.w    indent_count(a5),d2
  6005. .B    addq    #1,d2
  6006.     tst.b    (a0)+
  6007.     bne.s    .B
  6008.     bsr     addstring        print filename
  6009.  
  6010.     tst.l    fib_DirEntryType(a5)
  6011.     bpl.s    .C
  6012. .F    move.l    fib_NumBlocks(a5),d0
  6013.     add.l    d0,temp4(a5)
  6014.     move.l    fib_Size(a5),d0
  6015.     add.l    d0,temp1(a5)        increase total size
  6016.     move.b    #" ",(a2)+
  6017.     moveq    #34,d1
  6018.     sub.w    d2,d1
  6019.     bsr    qdecpr
  6020.     bra.s    prlink
  6021. .C    moveq    #29,d1
  6022.     sub.w    d2,d1
  6023.     bpl.s    .D
  6024.     moveq    #0,d1
  6025. .D    move.b    #" ",(a2)+
  6026.     dbra    d1,.D
  6027.     lea    dirtext(pc),a1
  6028.     bsr    addstring
  6029. prlink    move.b    #" ",(a2)+
  6030.     move.b    #" ",(a2)+
  6031.     move.l    fib_DirEntryType(a5),d0
  6032.     moveq    #-6,d1
  6033.     cmp.l    d1,d0
  6034.     bne.s    .B
  6035.     move.b    #"S",-1(a2)
  6036.     bra.s    .A
  6037. .B    moveq    #4,d1
  6038.     cmp.l    d1,d0
  6039.     bne.s    .C
  6040.     move.b    #"H",-1(a2)
  6041.     bra.s    .A
  6042. .C    moveq    #-4,d1
  6043.     cmp.l    d1,d0
  6044.     bne.s    .A
  6045.     move.b    #"H",-1(a2)
  6046. .A    move.b    #" ",(a2)+
  6047.     addq.l    #1,temp2(a5)
  6048.     move.l    temp2(a5),d0        are we printing wide
  6049.     bpl.s    wpro
  6050.     btst    #0,d0
  6051.     beq.s    .F
  6052.     move.b    #LF,(a2)+
  6053. .F    clr.b    (a2)
  6054.     lea    temp2buf(a5),a1
  6055.     bra    pr_string        print string&return and return
  6056.  
  6057. wpro    btst    #29,temp2(a5)
  6058.     beq.s    .E
  6059.     move.l    a2,a0
  6060.     bsr    pr_pro2            print protection V2.0
  6061.     move.b    #" ",(a0)+
  6062.     move.l    a0,a2            (goes to temp2buf)
  6063.     btst    #24,temp2(a5)        protect flag ?
  6064.     bne.s    .E
  6065.     lea    fib_Date(a5),a1
  6066.     lea    -14(sp),sp
  6067.     lea    (sp),a0
  6068.     bsr    convert_time
  6069.     move.l    a2,a1
  6070.     bsr    qprint10
  6071.     move.b    #".",(a1)+
  6072.     bsr    qprint10
  6073.     move.b    #".",(a1)+
  6074.     bsr    qprint10
  6075.     move.b    #" ",(a1)+
  6076.     move.b    #" ",(a1)+
  6077.     bsr    qprint10
  6078.     move.b    #":",(a1)+
  6079.     bsr    qprint10
  6080.     move.b    #":",(a1)+
  6081.     bsr    qprint10
  6082.     move.b    #LF,(a1)+
  6083.     lea    14(sp),sp
  6084.     move.l    a1,a2
  6085. .E    clr.b    (a2)
  6086.     lea    temp2buf(a5),a1
  6087.     bsr    pr_string        print date/time V2.0
  6088.  
  6089.     move.l    d7,d1
  6090.     bsr    CurrentDir        d0=old current dir
  6091.     movem.l    d0/d4-d7/a3-a4,-(sp)
  6092.     move.l    d7,d6
  6093.     btst    #28,temp2(a5)
  6094.     beq    fort
  6095.     tst.b    fib_Comment(a5)
  6096.     beq.s    .A
  6097.     bsr    num_spc
  6098.     lea    farb2(pc),a1
  6099.     bsr    addstring
  6100.     move.b    #":",(a2)+
  6101.     clr.b    (a2)
  6102.     lea    temp2buf(a5),a1
  6103.     bsr    pr_string
  6104.     lea    fib_Comment(a5),a1
  6105.     bsr    pr_string        print Comment V2.0
  6106.     lea    farb1(pc),a1
  6107.     bsr    pr_stringlf
  6108.  
  6109. .A    cmp.w    #36,kickver(a5)
  6110.     blo    fort
  6111.     move.l    fib_DirEntryType(a5),d0
  6112.     bpl.s    .F
  6113.     neg.l    d0
  6114. .F    moveq    #4,d1
  6115.     cmp.l    d0,d1
  6116.     bne.s    .G
  6117.     lea    NewPrintBuffer(a5),a2    process hardlinks
  6118.     lea    farb2(pc),a1
  6119.     bsr    addstring
  6120.     lea    pfeil(pc),a1
  6121.     bsr    addstring
  6122.     lea    fib_FileName(a5),a0
  6123.     move.l    a0,d1
  6124.     moveq    #ACCESS_READ,d2
  6125.     jsr    _LVOLock(a6)
  6126.     tst.l    d0
  6127.     beq.s    .C
  6128.     move.l    a2,a0
  6129.     bsr    eval_full_path
  6130.     jsr    _LVOUnLock(a6)
  6131.     bra.s    .B
  6132. .G    moveq    #-6,d0
  6133.     cmp.l    fib_DirEntryType(a5),d0    check whether is softlink
  6134.     bne.s    fort
  6135.     lea    fib_FileName(a5),a2    process softlinks
  6136.     move.l    a2,d1
  6137.     jsr    _LVODeviceProc(a6)
  6138.     move.l    d0,d4
  6139.     beq.s    .C
  6140.     move.l    a2,d3    path (filename)
  6141.     lea    NewPrintBuffer(a5),a2
  6142.     lea    farb2(pc),a1
  6143.     bsr    addstring
  6144.     lea    pfeil(pc),a1
  6145.     bsr    addstring
  6146.     move.l    d4,d1    msgport of device
  6147.     move.l    d6,d2    lock on current dir
  6148.     move.l    a2,d4    buffer
  6149.     moveq    #120,d5    size of buffer
  6150.     jsr    _LVOReadLink(a6)
  6151. .C    bsr    maybeDOSerr
  6152.     beq.s    fort
  6153. .B    lea    NewPrintBuffer(a5),a1
  6154.     bsr    pr_string        ;print softlink V2.3
  6155.     lea    farb1(pc),a1
  6156.     bsr    pr_stringlf
  6157.  
  6158. fort    move.w    temp2(a5),d0    get upper two bytes
  6159.     and.w    #%0000010010010000,d0    copy,delete or join flag
  6160.     beq    .B        no: try protect
  6161.     btst    #25,temp2(a5)
  6162.     bne    .A        not process flag ?
  6163.  
  6164.     btst    #22,temp2+1(a5)        move flag ?
  6165.     beq.s    .E
  6166.     btst    #21,temp2+1(a5)        MOVE !
  6167.     beq.s    .E    need not try to rename
  6168.     tst.l    fib_DirEntryType(a5)
  6169.     bpl.s    .D    delete dir
  6170.     lea    fib_FileName(a5),a0
  6171.     bsr    MoveFile
  6172.     bne    .A
  6173.     bclr    #21,temp2+1(a5)    cannot rename
  6174.  
  6175. .E    btst    #23,temp2+1(a5)        copy flag ?
  6176.     beq.s    .D
  6177.     tst.l    fib_DirEntryType(a5)
  6178.     bpl    .H
  6179.     lea    fib_FileName(a5),a0    COPY !
  6180.     bsr    CopyFileToDir
  6181.     bne    .A        error occured->not delete
  6182.  
  6183. .D    btst    #26,temp2(a5)        delete flag ?
  6184.     beq.s    .C
  6185.     lea    fib_FileName(a5),a0    DELETE !
  6186.     tst.l    fib_DirEntryType(a5)
  6187.     bpl.s    .I    
  6188.     bsr    DoDelete
  6189.     bra.s    .C
  6190. .I    bsr    DoDelete2
  6191.  
  6192. .C    btst    #20,temp2+1(a5)        join flag ?
  6193.     beq.s    .B
  6194.     tst.l    fib_DirEntryType(a5)
  6195.     bpl.s    .H
  6196.     lea    fib_FileName(a5),a0    JOIN !
  6197.     bsr    JoinFile
  6198.  
  6199. .B    btst    #24,temp2(a5)        protect flag ?
  6200.     beq.s    .A
  6201.     tst.b    recurs_flag(a5)        PROTECT !
  6202.     beq.s    .F
  6203.     tst.l    fib_DirEntryType(a5)    no recursive dir protects
  6204.     bpl.s    .H
  6205. .F    move.l    fib_Protection(a5),d2
  6206.     move.l    d2,d0
  6207.     eor.b    #$0f,d2
  6208.     and.l    temp6(a5),d2
  6209.     or.l    temp5(a5),d2
  6210.     eor.b    #$0f,d2
  6211.     cmp.l    d2,d0
  6212.     beq.s    .H
  6213.     move.l    d2,fib_Protection(a5)
  6214.     lea    fib_FileName(a5),a0
  6215.     move.l    a0,d1
  6216.     jsr    _LVOSetProtection(a6)
  6217.     bsr    maybeDOSerr
  6218.     lea    temp2buf(a5),a2    print new protection
  6219.     lea    pfeil(pc),a1
  6220.     bsr    addstring
  6221.     move.l    a2,a0
  6222.     bsr    pr_pro2
  6223.     move.b    #LF,(a0)+
  6224.     clr.b    (a0)
  6225.     bsr    pr_string    (temp2buf in a1)
  6226.  
  6227.     bra.s    .A
  6228. .H    bsr    pr_lf
  6229. .A    movem.l    (sp)+,d0/d4-d7/a3-a4
  6230.     move.l    d0,d1
  6231.     bsr    CurrentDir
  6232.     rts
  6233.  
  6234. qprint10 move.w    (a0)+,d0    V2.0
  6235. qpr10    ext.l    d0    (also used by More, GuruIt and Pipe)
  6236.     divu    #10,d0    Value in d0 , Buffer in a1
  6237.     add.b    #"0",d0
  6238.     move.b    d0,(a1)+
  6239.     swap    d0
  6240.     add.b    #"0",d0
  6241.     move.b    d0,(a1)+
  6242.     rts
  6243.  
  6244. num_spc    lea    temp2buf(a5),a2        V2.0
  6245.     move.w    indent_count(a5),d0
  6246.     moveq    #$3f,d1
  6247.     and.l    d1,d0
  6248.     bra.s    .B
  6249. .A    move.b    #" ",(a2)+    the preceding spaces
  6250. .B    dbra    d0,.A
  6251.     rts
  6252.  
  6253. addstring move.b (a1)+,(a2)+
  6254.     bne.s    addstring
  6255.     subq.l    #1,a2
  6256.     rts
  6257.  
  6258. qdecpr    * Number in d0.l , Length in d1.w , adds string to buffer in a2
  6259.     movem.l    d2/d3/a0,-(sp)    ;Prints Decimal Number in (a2)
  6260.     lea    -12(sp),sp
  6261.     move.l    sp,a0
  6262.     move.l    d1,d3
  6263.     moveq    #0,d2
  6264. .A    moveq    #LF,d1
  6265.     bsr    div_32
  6266.     add.b    #$30,d1
  6267.     move.b    d1,(a0)+
  6268.     addq.w    #1,d2
  6269.     tst.l    d0
  6270.     bne.s    .A
  6271.     sub.w    d2,d3
  6272.     subq.w    #1,d3
  6273.     bmi.s    .B
  6274. .D    move.b    #" ",(a2)+
  6275.     dbra    d3,.D
  6276. .B    subq.w    #1,d2
  6277. .C    move.b    -(a0),(a2)+
  6278.     dbra    d2,.C
  6279.     lea    12(sp),sp
  6280.     movem.l    (sp)+,d2/d3/a0
  6281.     rts
  6282.  
  6283. fixsoftlink
  6284.     moveq    #3,d0
  6285.     cmp.l    fib_DirEntryType(a5),d0        is it a softlink ?
  6286.     bne.s    .A
  6287.     move.l    #-6,fib_DirEntryType(a5)    make it look like a file
  6288. .A    rts
  6289.  
  6290. *** CHECK CTRL_C
  6291. ** RETURN NE if ctrl c, EQ if not
  6292. check_c    movem.l    d0-d1/a0-a1/a6,-(sp)    checks if CTRL-C pressed
  6293.     tst.b    break_flag(a5)
  6294.     bne.s    .A
  6295.     moveq    #0,d0
  6296.     moveq    #0,d1
  6297.     move.l    4.w,a6
  6298.     bset    #SIGBREAKB_CTRL_C,d1
  6299.     jsr    _LVOSetSignal(a6)
  6300.     btst    #SIGBREAKB_CTRL_C,d0
  6301.     beq.s    .B
  6302. .A    move.l    dosbase(a5),a6
  6303.     move.l    #304,d0
  6304.     bsr    pr_DOSerr
  6305.     move.b    #1,break_flag(a5)    NE: STOP!!!
  6306.     movem.l    (sp)+,d0-d1/a0-a1/a6
  6307.     rts
  6308. .B    clr.b    break_flag(a5)
  6309.     moveq    #0,d0            EQ: no stop
  6310.     movem.l    (sp)+,d0-d1/a0-a1/a6
  6311.     rts
  6312.  
  6313.  
  6314. *ALLOCATE MEMORY D0=size D1=type
  6315. iwantmem    movem.l d1/a0-a1,-(sp)
  6316.     move.l    4.w,a6
  6317.     jsr    _LVOAllocMem(a6)
  6318.     move.l    dosbase(a5),a6
  6319.     moveq    #103,d1
  6320.     move.l    thistask(a5),a0
  6321.     move.l    d1,pr_Result2(a0)
  6322.     movem.l (sp)+,d1/a0-a1
  6323.     tst.l    d0
  6324.     rts
  6325. *FREEMEM A1=ptr to mem block D0=size
  6326. givemem    move.l    4.w,a6
  6327.     jsr    _LVOFreeMem(a6)
  6328.     move.l    dosbase(a5),a6
  6329.     rts
  6330.     
  6331.  
  6332. *REMOVE PATH A0-> source A1->destination
  6333. rempath    movem.l d0/a0-a2,-(sp)
  6334. rempath1    move.l a0,a2
  6335. rempath2    move.b (a0)+,d0
  6336.     cmp.b #'/',d0
  6337.     beq.s rempath1
  6338.     cmp.b #':',d0
  6339.     beq.s rempath1
  6340.     tst.b d0
  6341.     bne.s rempath2
  6342.     move.l a2,a0
  6343.     bsr cp_string
  6344.     movem.l (sp)+,d0/a0-a2
  6345.     rts
  6346.  
  6347.  
  6348. ** PRINT STRING (A1) USING indent_count(a5) AS A SPACE INDENT COUNT
  6349. prindent    movem.l    d7/a0-a1,-(sp)
  6350.     move.w    indent_count(a5),d7
  6351.     move.l    a1,a0
  6352.     and.w    #$3f,d7
  6353.     beq.s    .A
  6354.     bra.s    .B
  6355. .C    bsr    pr_space    print d7 spaces
  6356. .B    dbra    d7,.C
  6357.     move.l    a0,a1
  6358. .A    bsr    pr_string
  6359.     movem.l    (sp)+,d7/a0-a1
  6360.     rts
  6361.  
  6362. ** ENTRY A0 pts to parameter.
  6363. ** EXIT D0=lower case char after dash OR 0 if no dash command.
  6364. return_dash_option
  6365.     moveq    #0,d0
  6366.     cmp.b    #$22,-1(a0)    enclosed in quotes ?
  6367.     beq.s    .B
  6368.     cmp.b    #'-',(a0)    options start with a dash
  6369.     bne.s    .B
  6370.     tst.b    2(a0)        max. 1 char each option
  6371.     bne.s    .B
  6372. .A    move.b    1(a0),d0
  6373.     cmp.b    #'a',d0
  6374.     blo.s    .B
  6375.     cmp.b    #'z',d0
  6376.     bhi.s    .B
  6377.     sub.b    #$20,d0
  6378. .B    rts
  6379.  
  6380. check_q_r    ;checks for -q, -s or -r (or ALL) options, parm-ptr in a2
  6381.     lea    parm2(a5),a2
  6382.     clr.b    recurs_flag(a5)
  6383.     btst    #FLall,Flags+3(a5)
  6384.     beq.s    .A
  6385.     lea    alltx(pc),a0
  6386.     bsr    LookForOpt
  6387.     bne.s    .A
  6388.     move.b    #1,recurs_flag(a5)
  6389. .A    move.l    a2,a1
  6390.     move.l    (a1),d0
  6391.     beq.s    .E
  6392.     move.l    d0,a0
  6393.     bsr    return_dash_option
  6394.     tst.l    d0
  6395.     beq.s    .E
  6396.     cmp.b    #"R",d0
  6397.     bne.s    .B
  6398.     move.b    #1,recurs_flag(a5)    -r -> recursive
  6399.     bra.s    .G
  6400. .B    cmp.b    #"Q",d0
  6401.     bne.s    .C
  6402.     bset    #30,temp2(a5)        -q -> quick,nosort
  6403.     bra.s    .G
  6404. .C    cmp.b    #"S",d0
  6405.     bne.s    .E
  6406.     bclr    #30,temp2(a5)        -s -> noquick,sort
  6407. .G    lea    4(a1),a0
  6408. .F    move.l    (a0)+,(a1)+
  6409.     bne.s    .F
  6410.     bra.s    .A
  6411. .E    rts
  6412.  
  6413.  
  6414. CurrentDir    ;same as _LVOCurrentDir(a6)
  6415.     move.l    thistask(a5),a0
  6416.     lea    pr_CurrentDir(a0),a0
  6417.     move.l    (a0),d0
  6418.     move.l    d1,(a0)
  6419.     rts
  6420.  
  6421. *************************
  6422. *    DELETE        *    V2.3 new written
  6423. *************************
  6424. deletez    clr.l    temp2(a5)
  6425.     bset    #26,temp2(a5)
  6426.     bsr    check_q_r
  6427.     move.l    (a2),d0
  6428.     beq    too_less_args
  6429.     move.l    d0,a0
  6430.     lea    devicetx(pc),a1
  6431.     bsr    CheckOpt
  6432.     beq    deldevice    format device quick
  6433.     lea    forcetx(pc),a0
  6434.     bsr    LookForOpt    FORCE-flag ?
  6435.     subq.l    #1,d0
  6436.     move.l    d0,temp5(a5)
  6437.     bra    directory2    delete as many files as given
  6438.  
  6439. DoDelete    ;file to delete in a0
  6440.     bsr    AskYesNo    ASK first
  6441.     bne.s    DoDeEnd
  6442. DoDelete2
  6443.     move.l    a0,a2
  6444. .E    move.l    a2,d1
  6445.     jsr    _LVODeleteFile(a6)    delete file/dir
  6446.     tst.l    d0
  6447.     bne.s    .B
  6448. .D    jsr    _LVOIoErr(a6)
  6449.     cmp.l    #222,d0        delete-protected ?
  6450.     bne.s    .A
  6451.     tst.l    temp5(a5)    FORCE-flag ?
  6452.     beq.s    .A
  6453.     move.l    a2,d1
  6454.     moveq    #0,d2
  6455.     jsr    _LVOSetProtection(a6)
  6456.     tst.l    d0
  6457.     beq.s    .D
  6458.     bra.s    .E        try again
  6459. .A    btst    #22,temp2+1(a5)
  6460.     bne.s    .F        move: do not print lf
  6461.     bsr    pr_lf            error occured
  6462. .F    bsr    pr_DOSerr
  6463.     bra.s    DoDeEnd
  6464. .B    lea    deleteOK(pc),a1    delete successful
  6465.     btst    #22,temp2+1(a5)
  6466.     bne.s    DoDeEnd        move: do not print
  6467.     bsr    pr_string
  6468. DoDeEnd    rts
  6469.  
  6470.  
  6471. AskYesNo
  6472.     movem.l    d1-d3/a0-a2,-(sp)
  6473.     btst    #30,temp2(a5)    quick flag set
  6474.     bne.s    .B
  6475.     btst    #22,temp2+1(a5)    move-> do not ask
  6476.     bne.s    .B
  6477.     move.l    stdin(a5),d1
  6478.     beq.s    .B
  6479.     lea    yesnotx(pc),a1
  6480.     bsr    pr_string
  6481.     bsr    raw_on
  6482.     lea    temp2buf(a5),a2
  6483.     clr.b    (a2)
  6484.     move.l    a2,d2
  6485.     moveq    #20,d3    read only 1 char
  6486.     jsr    _LVORead(a6)
  6487.     clr.b    1(a2)
  6488.     cmp.b    #13,(a2)
  6489.     bne.s    .F
  6490.     move.b    #"Y",(a2)
  6491. .F    bclr    #5,(a2)
  6492.     move.l    a2,a1
  6493.     bsr    pr_string    show it
  6494.     bsr    pr_space
  6495.     bsr    rawh_off
  6496.     cmp.b    #"Y",(a2)    yes ?
  6497.     beq.s    .B
  6498.     cmp.b    #"A",(a2)    all ?
  6499.     bne.s    .A
  6500.     bset    #30,temp2(a5)    set quick flag
  6501.     bra.s    .B
  6502. .A    cmp.b    #"Q",(a2)    quit ?
  6503.     bne.s    .E
  6504.     move.b    #1,break_flag(a5)
  6505. .E    bsr    pr_lf
  6506. .C    moveq    #-1,d0        NO end
  6507.     bra.s    .D
  6508. .B    moveq    #0,d0        YES end
  6509. .D    movem.l    (sp)+,d1-d3/a0-a2
  6510.     rts
  6511.  
  6512. *************************
  6513. deldevice        ;formats device quick    V2.3
  6514.     bsr    CheckKS
  6515.     move.l    parm3(a5),d1
  6516.     beq    too_less_args
  6517.     move.l    d1,a2
  6518.     moveq    #-2,d2
  6519.     jsr    _LVOLock(a6)    lock on drive
  6520.     move.l    d0,d7
  6521.     beq    DOSerr
  6522.     move.l    d0,d1
  6523.     move.l    a5,d2        get info data into fib
  6524.     jsr    _LVOInfo(a6)
  6525.     tst.l    d0
  6526.     beq    DOSerrUL
  6527.     move.l    d7,d1
  6528.     jsr    _LVOUnLock(a6)
  6529.     lea    formatask(pc),a1
  6530.     bsr    pr_string
  6531.     bsr    rask
  6532.     tst.l    d0
  6533.     beq.s    .A
  6534.     move.l    parm4(a5),d4
  6535.     bne.s    .B
  6536.     move.l    id_VolumeNode(a5),a0
  6537.     add.l    a0,a0
  6538.     add.l    a0,a0
  6539.     move.l    $28(a0),a1    volumename
  6540.     add.l    a1,a1
  6541.     add.l    a1,a1
  6542.     lea    temp2buf(a5),a4
  6543.     move.l    a4,d4
  6544.     bsr    copy_bstr
  6545.     clr.b    (a4)
  6546. .B    move.l    parm5(a5),d0    check for filesystem
  6547.     beq.s    .D
  6548.     lea    ofs_tx(pc),a1
  6549.     move.l    d0,a0
  6550.     moveq    #0,d3
  6551. .E    bsr    CheckOpt
  6552.     bne.s    .F
  6553.     add.l    #"DOS"<<8,d3
  6554.     bra.s    .G
  6555. .F    addq.b    #1,d3
  6556.     cmp.b    #6,d3
  6557.     bne.s    .E
  6558. .D    move.l    id_DiskType(a5),d3    dostype
  6559. .G    move.l    a2,d1
  6560.     moveq    #-1,d2
  6561.     jsr    _LVOInhibit(a6)        disable drive
  6562.     tst.l    d0
  6563.     beq    DOSerr
  6564.     move.l    a2,d1
  6565.     move.l    d4,d2
  6566.     jsr    _LVOFormat(a6)        format it quick !
  6567.     bsr    maybeDOSerr
  6568.     move.l    a2,d1
  6569.     moveq    #0,d2
  6570.     jsr    _LVOInhibit(a6)        enable drive
  6571.     tst.l    d0
  6572.     beq    DOSerr
  6573. .A    moveq    #RETURN_OK,d0
  6574.     rts
  6575.  
  6576. *************************
  6577. *    PROTECT        *    V2.3 new written
  6578. *************************
  6579. protectz
  6580.     clr.l    temp2(a5)
  6581.     bset    #29,temp2(a5)    bit 29=verbose flag
  6582.     bset    #24,temp2(a5)    bit 24=protect flag
  6583.     bset    #30,temp2(a5)    bit 30=quick flag
  6584.     bsr    check_q_r
  6585.     tst.l    (a2)+
  6586.     beq    too_less_args
  6587.     clr.l    temp5(a5)
  6588.     clr.l    temp6(a5)
  6589. .A    move.l    (a2)+,d0
  6590.     beq.s    .D
  6591.     move.l    d0,a0
  6592.     cmp.b    #"+",(a0)    look for add-option
  6593.     bne.s    .B
  6594.     bsr    GetProtMask
  6595.     or.l    d0,temp5(a5)
  6596.     bra.s    .C
  6597. .B    cmp.b    #"-",(a0)    look for sub-option
  6598.     bne.s    .F
  6599.     bsr    GetProtMask
  6600.     or.l    d0,temp6(a5)
  6601.     bra.s    .C
  6602. .F    cmp.b    #"=",(a0)    look for equal-option
  6603.     bne.s    .A
  6604.     bsr    GetProtMask
  6605.     move.l    d0,temp5(a5)
  6606.     moveq    #-1,d0
  6607.     move.l    d0,temp6(a5)
  6608. .C    move.l    a2,a0
  6609.     lea    -4(a2),a1
  6610. .E    move.l    (a0)+,(a1)+    delete this parm
  6611.     bne.s    .E
  6612.     subq.l    #4,a2
  6613.     bra.s    .A
  6614.  
  6615. .D    moveq    #-1,d0
  6616.     eor.l    d0,temp6(a5)
  6617.     bra    directory2    jump into dir-lister
  6618.  
  6619.  
  6620. GetProtMask    ;a0=bits-string, d0=bit-mask
  6621.     moveq    #0,d0
  6622.     addq.l    #1,a0
  6623. .B    move.b    (a0)+,d1
  6624.     beq.s    .C
  6625.     moveq    #7,d2
  6626. .A    cmp.b    protflags(pc,d2.w),d1
  6627.     bne.s    .D
  6628.     bset    d2,d0
  6629.     bra.s    .B
  6630. .D    dbra    d2,.A
  6631.     lea    badprotbit(pc),a0
  6632.     bra    ErrorExit
  6633. .C    rts
  6634.  
  6635. pr_prot    lea    temp2buf(a5),a0        V2.0
  6636. pr_pro2    moveq    #7,d0
  6637.     move.l    fib_Protection(a5),d1
  6638.     eor.b    #$0f,d1
  6639. .A    move.b    #"-",(a0)+
  6640.     btst    d0,d1
  6641.     beq.s    .B
  6642.     move.b    protflags(pc,d0.w),-1(a0)
  6643. .B    dbra    d0,.A
  6644.     clr.b    (a0)
  6645.     lea    temp2buf(a5),a1
  6646.     rts
  6647.  
  6648. protflags    dc.b    'dewrapsh'
  6649.  
  6650. *************************
  6651. *    JOIN        *    V2.3 new written
  6652. *************************
  6653. joinz    clr.l    temp2(a5)
  6654.     bset    #20,temp2+1(a5)    set join flag
  6655.     bsr    check_q_r
  6656.     clr.l    devproc(a5)
  6657.     clr.l    temp5(a5)    destination file
  6658.     clr.l    temp6(a5)    memory block
  6659.     lea    parm2(a5),a3
  6660.     addq.l    #4,a3
  6661.     tst.l    (a3)+
  6662.     beq    too_less_args    no arg given
  6663. .A    tst.l    (a3)+
  6664.     bne.s    .A
  6665.     move.l    -8(a3),a2    get last parm
  6666.     clr.l    -8(a3)        and remove it
  6667.     move.l    a2,d1
  6668.     move.l    #MODE_READWRITE,d2
  6669.     jsr    _LVOOpen(a6)
  6670.     move.l    d0,temp5(a5)    open output file and store it
  6671.     beq    DOSerr
  6672.     move.l    d0,d1
  6673.     moveq    #0,d2
  6674.     moveq    #1,d3
  6675.     jsr    _LVOSeek(a6)    look for end, no error checking
  6676.     bsr    GetCopyBlock
  6677.     beq    .F
  6678.     move.l    d0,temp6(a5)
  6679.     bsr    directory2    DO COPY !
  6680.     bsr    FreeCopyBlock
  6681. .F    move.l    temp5(a5),d1
  6682.     jsr    _LVOClose(a6)
  6683.     moveq    #RETURN_OK,d0
  6684.     rts
  6685.  
  6686. JoinFile    ;a0=filename, temp5=outfile, temp6=mem block
  6687.     moveq    #0,d4
  6688.     move.l    a0,d1
  6689.     move.l    #MODE_OLDFILE,d2
  6690.     jsr    _LVOOpen(a6)    open input file
  6691.     move.l    d0,d4        d4=input file handle
  6692.     beq    perr3
  6693.     move.l    temp5(a5),d5    d5=output file handle
  6694.     bsr    PerformCopy        Main Stuff !
  6695.     bne.s    .C
  6696.     lea    processOK(pc),a1    all OK
  6697.     bsr    pr_string
  6698.     moveq    #RETURN_OK,d0
  6699. .C    rts
  6700.  
  6701. *************************
  6702. *    MOVE        *    V2.3
  6703. *************************
  6704. movez    clr.l    temp2(a5)
  6705.     bset    #22,temp2+1(a5)    set move flag
  6706.     bset    #21,temp2+1(a5)    set rename flag
  6707.     bset    #26,temp2(a5)    set delete flag
  6708.     clr.l    temp7(a5)    holds full dest. pathname
  6709.     bra.s    Copy1
  6710.  
  6711. MoveFile    ;Filename in a0
  6712.     move.l    a0,a3
  6713.     move.l    temp7(a5),a0    path
  6714.     move.l    a3,a1        name
  6715.     lea    temp2buf(a5),a2    path+name
  6716.     bsr    addpath
  6717.     move.l    a2,d2
  6718.     move.l    a3,d1
  6719.     jsr    _LVORename(a6)
  6720.     tst.l    d0
  6721.     beq.s    .A
  6722.     lea    moveOK(pc),a1
  6723.     bsr    pr_string
  6724.     moveq    #1,d0
  6725. .A    rts
  6726.  
  6727. *************************
  6728. *    COPY        *    V2.3 new written
  6729. *************************
  6730. copyz    clr.l    temp2(a5)
  6731. Copy1    bset    #23,temp2+1(a5)    set copy flag
  6732.     bset    #30,temp2(a5)    bit 30=quick flag
  6733.     bsr    check_q_r
  6734.     clr.l    devproc(a5)
  6735.     clr.l    temp5(a5)    destination dir
  6736.     clr.l    temp6(a5)    memory block
  6737.     lea    parm2(a5),a2
  6738.     tst.l    (a2)+
  6739.     beq    too_less_args    *no arg given
  6740.     tst.l    (a2)+
  6741.     bne.s    Copy2
  6742.     lea    null(pc),a2    *one arg -> copy to current dir
  6743.     bra    Copy3b
  6744.  
  6745. Copy2    tst.l    (a2)+
  6746.     bne    Copy3
  6747.     move.l    -8(a2),a0    *two args -> copy to file/dir
  6748.     clr.l    -8(a2)        get it and remove it
  6749.     move.l    a0,a2
  6750.     move.l    parm2(a5),a0
  6751.     bsr    check_wild
  6752.     tst.l    d0
  6753.     beq    Copy3b        wildcards->copy to dir
  6754.     move.l    parm2(a5),d1
  6755.     btst    #22,temp2+1(a5)
  6756.     beq.s    .B        move: try to rename
  6757.     move.l    a2,d2
  6758.     jsr    _LVORename(a6)
  6759.     tst.l    d0
  6760.     beq.s    .B        move:    failed
  6761.     move.l    parm2(a5),a1        OK
  6762.     bsr    pr_string
  6763.     bsr    pr_space
  6764.     lea    moveOK(pc),a1
  6765.     bsr    pr_string
  6766.     moveq    #RETURN_OK,d0
  6767.     rts
  6768. .B    move.l    parm2(a5),d1
  6769.     move.l    #MODE_OLDFILE,d2    try to copy file to file:
  6770.     jsr    _LVOOpen(a6)    try to open input file    (d4)
  6771.     move.l    d0,d4
  6772.     beq.s    Copy3b        input not found->maybe a dir
  6773.     move.l    a2,d1
  6774.     move.l    #MODE_NEWFILE,d2
  6775.     jsr    _LVOOpen(a6)    try to open output file (d5)
  6776.     move.l    d0,d5
  6777.     bne.s    .D
  6778.     bsr    closett
  6779.     bra.s    Copy3b
  6780. .D    move.l    parm2(a5),a1
  6781.     bsr    pr_string
  6782.     bsr    pr_space
  6783.     bsr    GetCopyBlock
  6784.     bne.s    .A
  6785.     bsr    closett
  6786.     bra    resi_no_mem
  6787. .A    bsr    PerformCopy    do copy !
  6788.     move.l    d0,d4
  6789.     bsr    FreeCopyBlock
  6790.     tst.l    d4        error occured ?
  6791.     bne.s    .E
  6792.     btst    #22,temp2+1(a5)        move flag ?
  6793.     beq.s    .C
  6794.     move.l    parm2(a5),a0
  6795.     bsr    DoDelete    move: delete old file
  6796. .C    lea    copyOK(pc),a1        all OK
  6797.     bsr    pr_string
  6798. .E    move.l    d4,d0
  6799.     rts
  6800.  
  6801. Copy3    tst.l    (a2)+        *three or more args -> copy them to dir
  6802.     bne.s    Copy3        look for last parm
  6803.     move.l    -8(a2),a0    get it
  6804.     clr.l    -8(a2)        and remove it
  6805.     move.l    a0,a2
  6806. Copy3b    move.l    a2,d1
  6807.     moveq    #ACCESS_READ,d2
  6808.     jsr    _LVOLock(a6)    try to lock dir
  6809.     move.l    d0,d7
  6810.     bne.s    .B        found
  6811.     jsr    _LVOIoErr(a6)
  6812.     cmp.l    #205,d0        object not found ?
  6813.     beq.s    .C
  6814.     bra    pr_galactic    no
  6815. .C    move.l    a2,d1
  6816.     jsr    _LVOCreateDir(a6)    yes, make dir
  6817.     move.l    d0,d1
  6818.     beq    DOSerr
  6819.     jsr    _LVOUnLock(a6)    unlock and try again
  6820.     move.l    a2,a1
  6821.     bsr    pr_string
  6822.     bsr    pr_space
  6823.     lea    makedirOK(pc),a1
  6824.     bsr    pr_string
  6825.     bra.s    Copy3b
  6826. .B    bsr    fibexam2
  6827.     tst.l    fib_DirEntryType(a5)    file or dir ?
  6828.     bpl.s    .E
  6829.     move.l    d7,d1
  6830.     jsr    _LVOUnLock(a6)    was not a dir
  6831.     move.l    #212,d0
  6832.     bra    pr_galactic
  6833. .E    move.l    d7,temp5(a5)    was a dir: store lock
  6834.     lea    -80(sp),sp
  6835.     move.l    sp,temp7(a5)
  6836.     bsr    AdjustPath    move: get full path
  6837.     move.l    a2,d1
  6838.     jsr    _LVODeviceProc(a6)
  6839.     move.l    d0,devproc(a5)
  6840.     bsr    GetCopyBlock
  6841.     beq    .F
  6842.     bsr    directory2    DO COPY !
  6843.     bsr    FreeCopyBlock
  6844. .F    lea    80(sp),sp    space needed for move
  6845.     move.l    temp5(a5),d1
  6846.     jsr    _LVOUnLock(a6)    unlock dir
  6847.     moveq    #RETURN_OK,d0
  6848.     rts
  6849.  
  6850. GetCopyBlock
  6851.     move.l    copysize(a5),d0
  6852.     moveq    #1,d1
  6853.     bsr    iwantmem    get memory block
  6854.     move.l    d0,temp6(a5)
  6855.     bsr    maybeDOSerr
  6856.     rts
  6857.  
  6858. FreeCopyBlock
  6859.     move.l    temp6(a5),a1
  6860.     move.l    copysize(a5),d0
  6861.     bra    givemem        free memory block
  6862.  
  6863. CopyFileToDir    ;a0=filename
  6864. *current path set, destination path in temp5, memory block in temp6
  6865.     moveq    #0,d4
  6866.     moveq    #0,d5
  6867.     move.l    a0,a2
  6868.     move.l    a0,d1
  6869.     move.l    #MODE_OLDFILE,d2
  6870.     jsr    _LVOOpen(a6)    open input file
  6871.     move.l    d0,d4        d4=input file handle
  6872.     beq    perr3        read protected ?
  6873.     move.l    a2,a0
  6874.     lea    temp2buf(a5),a2
  6875.     move.l    a2,a1
  6876.     bsr    rempath
  6877.     move.l    temp5(a5),d1
  6878.     bsr    CurrentDir
  6879.     move.l    d0,a3        a3 holds current dir
  6880.     move.l    a2,d1
  6881.     move.l    #MODE_NEWFILE,d2
  6882.     jsr    _LVOOpen(a6)    open output file
  6883.     move.l    d0,d5        d5=output file handle
  6884.     beq    perr4        already exits/disk full ?
  6885.     move.l    a3,d1
  6886.     bsr    CurrentDir
  6887.     bsr    PerformCopy        Main Stuff !
  6888.     bne.s    .C
  6889.     cmp.l    fib_Size(a5),d6
  6890.     beq.s    .B
  6891.     lea    wrongsize(pc),a1    wrong size
  6892.     bsr    pr_string
  6893.     move.l    d6,d0
  6894.     bsr    print10
  6895.     bsr    pr_lf
  6896.     bra.s    .A
  6897. .B    lea    copyOK(pc),a1        all OK
  6898.     bsr    pr_string
  6899. .A    moveq    #RETURN_OK,d0
  6900. .C    rts
  6901.  
  6902. PerformCopy        ;dest. filename in a2, d4,d5:filehandles
  6903.     moveq    #-1,d6        d6 holds maximum filesize
  6904. PerformCopy1
  6905. .A    move.l    d4,d1
  6906.     move.l    temp6(a5),d2
  6907.     move.l    copysize(a5),d3
  6908.     cmp.l    d3,d6
  6909.     bhi.s    .E
  6910.     move.l    d6,d3
  6911. .E    jsr    _LVORead(a6)    read a block
  6912.     move.l    d0,d3
  6913.     bmi    perr2        read error ?
  6914.     beq.s    recoend
  6915.     move.l    d5,d1
  6916.     move.l    temp6(a5),d2
  6917.     jsr    _LVOWrite(a6)    write as much as read
  6918.     tst.l    d0
  6919.     bmi    perr2        disk full ?
  6920.     cmp.l    d0,d3
  6921.     bne    perr2        disk full ?
  6922.     cmp.l    copysize(a5),d3
  6923.     bne.s    .B        buffer not filled by Read
  6924.     lea    dot(pc),a1
  6925.     bsr    pr_string    print dots as progress-indicator
  6926. .B    sub.l    d0,d6        sum up size in d6
  6927.     beq.s    recoend
  6928.     bsr    check_c        check for CTRL-C break
  6929.     beq.s    .A
  6930. recoend    bsr    closett
  6931.     addq.l    #1,d6
  6932.     neg.l    d6        calculate real filesize
  6933. adjust    tst.l    devproc(a5)
  6934.     beq.s    .A
  6935.     move.l    temp5(a5),d1
  6936.     bsr    CurrentDir
  6937.     move.l    d0,a3
  6938.     move.l    a2,d1
  6939.     move.l    fib_Protection(a5),d2
  6940.     beq.s    .D
  6941.     jsr    _LVOSetProtection(a6)    set old protection
  6942.     tst.l    d0
  6943.     beq    perr4
  6944. .D    move.l    a2,d1
  6945.     lea    fib_Comment(a5),a0    copy comment
  6946.     tst.b    (a0)
  6947.     beq.s    .C
  6948.     move.l    a0,d2
  6949.     jsr    _LVOSetComment(a6)
  6950.     tst.l    d0
  6951.     beq    perr4
  6952. .C    bsr    clearArgs        set old date
  6953.     lea    fib_Date(a5),a0
  6954.     move.l    a0,myArg4(a5)
  6955.     move.l    devproc(a5),packettask(a5)
  6956.     move.l    temp5(a5),myArg2(a5)
  6957.     lea    NewPrintBuffer(a5),a1
  6958.     move.l    a1,d2
  6959.     lsr.l    #2,d2
  6960.     move.l    d2,myArg3(a5)
  6961.     addq.l    #1,a1
  6962.     moveq    #-1,d0
  6963. .B    addq.l    #1,d0
  6964.     move.b    (a2)+,(a1)+
  6965.     bne.s    .B
  6966.     move.b    d0,NewPrintBuffer(a5)
  6967.     moveq    #ACTION_SET_DATE,d0
  6968.     move.l    d0,packettype(A5)
  6969.     bsr    sendpacket
  6970.     tst.l    sp_res1(a5)
  6971.     beq    perr4
  6972.     move.l    a3,d1
  6973.     bsr    CurrentDir
  6974. .A    moveq    #RETURN_OK,d0
  6975.     rts
  6976.  
  6977. perr4    move.l    a3,d1
  6978.     bsr    CurrentDir
  6979.     bra.s    perr1
  6980. perr2
  6981. perr3    move.l    thistask(a5),a0
  6982.     move.l    pr_Result2(a0),-(sp)
  6983.     bsr    closett
  6984.     move.l    thistask(a5),a0
  6985.     move.l    (sp)+,pr_Result2(a0)
  6986. perr1    jsr    _LVOIoErr(a6)
  6987.     cmp.l    #221,d0            disk full ?
  6988.     bne.s    .A
  6989.     tst.l    devproc(a5)        is dest. filename in a2 ?
  6990.     beq.s    .C
  6991.     move.l    d0,-(sp)
  6992.     move.l    temp5(a5),d1
  6993.     bsr    CurrentDir
  6994.     move.l    d0,a3
  6995.     move.l    a2,d1
  6996.     jsr    _LVODeleteFile(a6)    delete incomlete file
  6997.     move.l    a3,d1
  6998.     bsr    CurrentDir
  6999.     move.l    (sp)+,d0
  7000. .C    move.b    #1,break_flag(a5)    break if disk is full
  7001. .A    bsr    pr_lf
  7002.     bsr    pr_DOSerr
  7003.     moveq    #RETURN_ERROR,d0
  7004.     rts
  7005.  
  7006. closett    move.l    d4,d1    ;close files in d4 & d5
  7007.     beq.s    .A
  7008.     btst    #19,temp2+1(a5)    split: do not close infile
  7009.     bne.s    .A
  7010.     jsr    _LVOClose(a6)
  7011.     moveq    #0,d4
  7012. .A    move.l    d5,d1
  7013.     beq.s    .B
  7014.     btst    #20,temp2+1(a5)    join: do not close outfile
  7015.     bne.s    .B
  7016.     jsr    _LVOClose(a6)
  7017.     moveq    #0,d5
  7018. .B    rts
  7019.  
  7020.  
  7021.  
  7022. *************************************************************
  7023. * read a file to memory
  7024. * ENTRY A0=name
  7025. * EXIT  D0=address, D1=size
  7026. readfile    movem.l    d2-d7/a0-a4,-(sp)
  7027.     move.l    a0,d1
  7028.     move.l    a0,a4
  7029.     move.l    #MODE_OLDFILE,d2
  7030.     jsr    _LVOOpen(a6)    try to open it in current dir
  7031.     move.l    d0,d4        d4=filehandle
  7032.     bne.s    .A
  7033.     moveq    #-1,d1        Don't request
  7034.     bsr    changeWindowPtr
  7035.     lea    paths(pc),a0
  7036.     move.l    a4,a1
  7037.     lea    tempbuf(a5),a2
  7038.     bsr    addpath
  7039.     move.l    a2,d1
  7040.     move.l    #MODE_OLDFILE,d2
  7041.     jsr    _LVOOpen(a6)    try to open it in S: dir
  7042.     move.l    d0,d4
  7043.     beq    reader
  7044.     moveq    #0,d1        request on
  7045.     bsr    changeWindowPtr
  7046.  
  7047. .A    move.l    d4,d7        d7=filehandle to close
  7048.     bsr    readdata        open succeded
  7049.     move.l    d4,d1
  7050.     jsr    _LVOClose(a6)    close it
  7051. readfileend
  7052.     move.l    d6,d0
  7053.     move.l    d5,d1
  7054.     movem.l    (sp)+,d2-d7/a0-a4
  7055.     rts
  7056.  
  7057. * read things from stdin to memory
  7058. * EXIT  D0=address, D1=size
  7059. readstdin    movem.l    d2-d7/a0-a4,-(sp)
  7060.     move.l    inhandle(a5),d4
  7061.     moveq    #0,d7        do not close filehandle
  7062.     bsr    readdata
  7063.     bra.s    readfileend
  7064.  
  7065. * read the contents of a file to memory
  7066. * ENTRY: d4=filehandle
  7067. * EXIT:  d5=size, d6=address of memory block
  7068. readdata    moveq    #1,d3
  7069.     moveq    #0,d2
  7070.     move.l    d4,d1
  7071.     jsr    _LVOSeek(a6)
  7072.     tst.l    d0
  7073.     bmi.s    reader2
  7074.     moveq    #-1,d3
  7075.     moveq    #0,d2
  7076.     move.l    d4,d1
  7077.     jsr    _LVOSeek(a6)
  7078.     move.l    #-148,d1
  7079.     move.l    d0,d5    d5=size, handles also powerpacked files
  7080.     beq.s    reader4
  7081.     bmi.s    reader2
  7082.     moveq    #1,d1
  7083.     bsr    iwantmem
  7084.     move.l    d0,d6    d6=addr
  7085.     beq    reader2
  7086.     move.l    d6,d2
  7087.     move.l    d5,d3
  7088.     move.l    d4,d1
  7089.     jsr    _LVORead(a6)    READ IT
  7090.     tst.l    d0
  7091.     bmi    reader3
  7092.     rts
  7093.  
  7094. reader4    move.l    d1,-(sp)
  7095.     bra.s    reade22
  7096. reader3    move.l    d6,a1
  7097.     move.l    d5,d0
  7098.     bsr    givemem
  7099. reader2    move.l    thistask(a5),a0
  7100.     move.l    pr_Result2(a0),-(sp)
  7101. reade22    move.l    d7,d1
  7102.     beq.s    .A
  7103.     jsr    _LVOClose(a6)
  7104. .A    move.l    thistask(a5),a0
  7105.     move.l    (sp)+,pr_Result2(a0)
  7106. reader    moveq    #0,d1
  7107.     bsr    changeWindowPtr
  7108.     bra    DOSerr
  7109.  
  7110. *****************
  7111. *    MORE    *
  7112. *****************
  7113. morez    lea    parm2(a5),a0
  7114.     tst.b    redirect_in(a5)
  7115.     bne.s    .A
  7116.     move.l    (a0),d2
  7117.     beq    too_less_args
  7118.     addq.l    #4,a0
  7119. .A    moveq    #0,d4
  7120.     move.l    (a0),d0
  7121.     beq    .C
  7122.     move.l    d0,a1
  7123.     bsr    convert_ASCII_to_num
  7124.     beq    bad_number_error
  7125.     tst.w    d0
  7126.     beq.s    .C
  7127.     subq.w    #1,d0
  7128.     move.w    d0,d4
  7129.  
  7130. .C    tst.b    redirect_in(a5)
  7131.     bne.s    .B
  7132.     move.l    d2,a0
  7133.     bsr    readfile    read from file
  7134.     bra.s    .D
  7135. .B    bsr    readstdin    read from inhandle
  7136. .D    moveq    #0,d2
  7137. ViewMore        ;Jump-In to review the buffer
  7138.     move.l    d0,-(sp)    push address
  7139.     move.l    d1,-(sp)    push size
  7140.     move.l    d0,a0
  7141.     cmp.l    #$3f3,(a0)
  7142.     bne.s    .B
  7143.     move.l    #212,d0
  7144.     bsr    pr_DOSerr
  7145.     bra.s    .A
  7146. .B    bsr    make_screen
  7147. .A    move.l    (sp)+,d0
  7148.     move.l    (sp)+,a1
  7149.     bsr    givemem
  7150.     moveq    #RETURN_OK,D0
  7151.     RTS
  7152.  
  7153. make_screen    * more main-routine, also used for help
  7154. * Entry: d0=start adress, d1=length, d4=number of lines or 0, d2=lookback
  7155.     movem.l    d0-d2,-(sp)
  7156.     addq.b    #1,noreview_flag(a5)
  7157.     move.l    ConsoleSwitch(a5),temp1(a5)
  7158.     move.l    thistask(a5),a3
  7159.     move.l    pr_ConsoleTask(a3),ConsoleSwitch(a5)
  7160.     bsr    raw_on
  7161. .F    btst    #FLcutline,Flags+3(a5)
  7162.     beq.s    .G
  7163.     lea    cutontx(pc),a1
  7164.     bsr    pr_string
  7165. .G    tst.w    d4
  7166.     bne.s    .A
  7167.     bsr    GetWinSize
  7168.     move.w    d0,d4
  7169. .A    movem.l    (sp)+,d0-d2
  7170.     move.w    d4,line_count(a5)
  7171.     move.l    d0,d5    d5=start
  7172.     move.l    d0,a4    a4=ptr
  7173.     move.l    d0,a3
  7174.     move.l     d0,d6
  7175.     add.l    d1,d6    d6=end addr
  7176.     tst.l    d2
  7177.     beq.s    mk_screen
  7178.     move.l    d6,a4
  7179.     bra    look_back
  7180. mk_screen
  7181.     lea    clrhide(pc),a1
  7182.     bsr    pr_string
  7183.     move.w    line_count(a5),d2
  7184.     move.l    a4,-(sp)
  7185.     moveq    #0,d0
  7186.     bra.s    .A
  7187. .C    moveq    #1,d0    PRINT SCREEN FULL OF LINES
  7188. .A;    bsr    pr_line
  7189. .B    cmp.l    d6,a4    check against end
  7190.     beq.s    .E
  7191.     move.b    (a4)+,d0
  7192.     cmp.b    #LF,d0
  7193.     bne.s    .B
  7194.     dbra    d2,.C
  7195.     move.l    a4,a3    A3 points to end of page marker    
  7196. .E    move.l    a4,d7    D7 points to end
  7197.     move.l    (sp)+,a4
  7198. ;    bra    waitabit
  7199.  
  7200.     move.l    a4,d2
  7201.     move.l    outhandle(a5),d1
  7202.     beq.s    waitabit
  7203.     move.l    d7,d3
  7204.     sub.l    a4,d3
  7205.     subq.l    #1,d3
  7206.     bmi.s    waitabit    don't print if 0
  7207.     cmp.l    d7,d6
  7208.     bne.s    .D
  7209.     cmp.l    a3,d7
  7210.     beq.s    .D
  7211.     addq.l    #1,d3
  7212. .D    jsr    _LVOWrite(a6)
  7213.  
  7214. waitabit    
  7215.     move.l    stdin(a5),d1
  7216.     beq    cloga
  7217.     lea    tempbytes(a5),a0
  7218.     move.l    a0,d2
  7219.     moveq    #1,d3
  7220.     jsr    _LVORead(a6)        wait for space key
  7221. .A    moveq    #0,d0            clear top bytes
  7222.     move.b    tempbytes(a5),d0    test byte of input line
  7223.     cmp.b    #$9b,d0
  7224.     beq.s    waitabit        CSI ? Try again !
  7225. tastes    cmp.b    #'a',d0
  7226. ;    blo.s    go_upper
  7227. ;    sub.b    #$20,d0
  7228.  
  7229. go_upper    cmp.b    morekeys+1(a5),d0        cursor down ?
  7230.     beq.s    .G
  7231.     cmp.b    #"2",d0
  7232.     bne.s    ck_up
  7233. .G    cmp.l    d7,d6
  7234.     beq    waitabit
  7235.     lea    scroll_up_tx(pc),a1    SCROLL UP ONE LINE,
  7236.     bsr    pr_string    SEND CURSOR TO START OF LINE
  7237. .B    cmp.l    d6,a4    advance one line
  7238.     beq.s    .C
  7239.     move.b    (a4)+,d0
  7240.     cmp.b    #LF,d0
  7241.     bne.s    .B
  7242. .C    cmp.l    d6,a3    move a3 down one line too
  7243.     beq.s    .D
  7244.     move.b    (a3)+,d0
  7245.     cmp.b    #LF,d0
  7246.     bne.s    .C
  7247. .D    move.l    a4,-(sp)
  7248.     move.l    d7,a4
  7249. ;    cmp.l    d7,d6
  7250. ;    beq.s    .A
  7251.     moveq    #0,d0
  7252.     bsr    pr_line    print line from d7
  7253. .A    cmp.l    d6,a4    advance D7 one line
  7254.     beq.s    .E
  7255.     move.b    (a4)+,d0
  7256.     cmp.b    #LF,d0
  7257.     bne.s    .A
  7258. .E    move.l    a4,d7
  7259.     move.l    (sp)+,a4
  7260.     bra    waitabit
  7261.  
  7262. ck_up    cmp.b    morekeys+0(a5),d0        V2.0    cursor up ?
  7263.     beq.s    .G
  7264.     cmp.b    #"8",d0
  7265.     bne.s    ck_fwd
  7266. .G    cmp.l    d5,a4
  7267.     beq    waitabit
  7268.     lea    scroll_down_tx(pc),a1    SCROLL DOWN ONE LINE,
  7269.     bsr    pr_string    SEND CURSOR TO TOP LEFT
  7270.     cmp.l    d5,a4
  7271.     bls.s    .E
  7272.     subq.l    #1,a4
  7273. .B    cmp.l    d5,a4
  7274.     beq.s    .A
  7275.     cmp.b    #LF,-(a4)
  7276.     bne.s    .B
  7277.     addq.l    #1,a4
  7278. .A    moveq    #0,d0
  7279.     bsr    pr_line
  7280. .E    move.l    d7,a3
  7281.     cmp.l    d5,a3
  7282.     beq.s    .C
  7283.     subq.l    #1,a3
  7284. .D    cmp.l    d5,a3
  7285.     beq.s    .C
  7286.     cmp.b    #LF,-(a3)
  7287.     bne.s    .D
  7288.     addq.l    #1,a3
  7289. .C    move.l    a3,d7
  7290.     lea    temp2buf(a5),a1
  7291.     move.b    #$9b,(a1)+
  7292.     move.w    line_count(a5),d0
  7293.     addq.w    #1,d0
  7294.     bsr    qpr10
  7295.     move.b    #"H",(a1)+
  7296.     clr.b    (a1)
  7297.     lea    temp2buf(a5),a1
  7298.     bsr    pr_string    CURSOR some lines down
  7299.     bra    waitabit
  7300.  
  7301. ck_fwd    cmp.b    morekeys+2(a5),d0    cursor right ?
  7302.     beq.s    .A
  7303.     cmp.b    #"3",d0
  7304.     beq.s    .A
  7305.     cmp.b    #" ",d0
  7306.     bne.s    ck_top
  7307. .A    cmp.l    d7,d6        one page forward
  7308.     beq    waitabit
  7309.     move.l    a3,a4
  7310.     bra    mk_screen
  7311. ck_top    cmp.b    morekeys+5(a5),d0    shift cursor up ?
  7312.     beq.s    .A
  7313.     cmp.b    #"7",d0
  7314.     bne.s    ck_bot
  7315. .A    cmp.l    d5,a4        start of text
  7316.     beq    waitabit
  7317.     move.l    d5,a4
  7318.     bra    mk_screen
  7319. ck_bot    cmp.b    morekeys+4(a5),d0    shift cursor down ?
  7320.     beq.s    .A
  7321.     cmp.b    #"1",d0
  7322.     bne.s    ck_back
  7323. .A    cmp.l    a3,d6        end of text
  7324.     beq    waitabit
  7325.     move.l    d6,a4
  7326.     bra.s    look_back
  7327. ck_back    cmp.b    morekeys+3(a5),d0    cursor left ?
  7328.     beq.s    .A
  7329.     cmp.b    #"9",d0
  7330.     beq.s    .A
  7331.     cmp.b    #8,d0    backspace
  7332.     bne.s    ck_nkey
  7333. .A    cmp.l    d5,a4        one page back
  7334.     beq    waitabit
  7335. look_back
  7336.     move.w    line_count(a5),d1
  7337.     addq.w    #1,d1
  7338. mlook2    cmp.l    d5,a4    check against start
  7339.     beq.s    .E
  7340.     move.b    -(a4),d0
  7341.     cmp.b    #LF,d0
  7342.     bne.s    mlook2
  7343.     dbra    d1,mlook2
  7344.     lea    1(a4),a4
  7345. .E    bra    mk_screen
  7346.  
  7347.  
  7348. ck_nkey    cmp.b    morekeys+8(a5),d0    V2.7    search next string ?
  7349.     bne.s    ck_skey
  7350.     bsr    raw_off
  7351.     lea    tempbuf(a5),a1
  7352.     bra.s    more_sn
  7353.  
  7354. ck_skey    cmp.b    morekeys+7(a5),d0    V2.0    search string ?
  7355.     bne.s    ck_jkey
  7356.     bsr    raw_off
  7357.     lea    msearch(pc),a1
  7358.     bsr    pr_string
  7359.     lea    tempbuf(a5),a2
  7360.     move.b    (a2),d4        save first char
  7361.     move.l    a2,d2
  7362.     moveq    #120,d3
  7363.     move.l    stdin(a5),d1
  7364.     beq.s    more_se
  7365.     jsr    _LVORead(a6)
  7366.     tst.l    d0
  7367.     bmi.s    more_se
  7368.     move.l    a2,a1
  7369.     add.l    d0,a2
  7370.     subq.l    #1,a2
  7371.     move.b    d4,(a2)
  7372.     cmp.l    a1,a2        just pressed return ?
  7373.     beq.s    more_sn
  7374.     clr.b    (a2)    no
  7375. more_sn    move.l    d5,a3
  7376.     move.l    a4,a0
  7377.     bsr    find_end_of_line
  7378.     move.l    a0,a2
  7379.     move.l    d6,a0
  7380.     bsr    searchSTR
  7381.     cmp.b    #LF,d0
  7382.     bne.s    more_se
  7383.     move.l    a1,a4    set begin of line on top
  7384.     bra.s    more_sx
  7385. more_se    bsr    DisplayBeep
  7386. more_sx    bsr    raw_on
  7387.     bra    mk_screen
  7388.  
  7389. ck_jkey    cmp.b    morekeys+9(a5),d0    V2.3    jump to % ?
  7390.     bne.s    ck_wkey
  7391.     bsr    raw_off
  7392.     lea    mjump(pc),a1
  7393.     bsr    pr_string
  7394.     lea    tempbuf(a5),a2
  7395.     move.l    a2,d2
  7396.     moveq    #120,d3
  7397.     move.l    stdin(a5),d1
  7398.     beq.s    .A
  7399.     jsr    _LVORead(a6)
  7400.     tst.l    d0
  7401.     bmi.s    .A
  7402.     move.l    a2,a1
  7403.     add.l    d0,a2
  7404.     subq.l    #1,a2
  7405.     cmp.l    a1,a2        just pressed return ?
  7406.     beq.s    .A
  7407.     clr.b    (a2)    no
  7408.     bsr    convert_ASCII_to_num
  7409.     beq.s    .A
  7410.     moveq    #100,d1
  7411.     cmp.l    d1,d0
  7412.     bhi.s    .A
  7413.     move.l    d6,d1
  7414.     sub.l    d5,d1    calc % of size
  7415.     bsr    mult_32x32
  7416.     moveq    #100,d1
  7417.     bsr    div_32
  7418.     move.l    d5,a4
  7419.     add.l    d0,a4    new pointer
  7420.     bsr    raw_on
  7421.     moveq    #0,d1
  7422.     bra    mlook2    search begin of line
  7423. .A    bsr    raw_on
  7424.     bra    mk_screen
  7425.  
  7426. ck_wkey    cmp.b    morekeys+10(a5),d0    V2.3    write text to file (or print) ?
  7427.     bne.s    ck_hkey
  7428.     bsr    raw_off
  7429.     lea    mwrite(pc),a1
  7430.     bsr    pr_string
  7431.     lea    tempbuf(a5),a2
  7432.     move.l    a2,d2
  7433.     moveq    #120,d3
  7434.     move.l    stdin(a5),d1
  7435.     beq.s    .C
  7436.     jsr    _LVORead(a6)
  7437.     move.l    a2,a1
  7438.     add.l    d0,a2
  7439.     subq.l    #1,a2
  7440.     clr.b    (a2)        null-end
  7441.     cmp.l    a1,a2        just pressed return ?
  7442.     beq.s    .C        yes,quit
  7443.     move.l    a1,d1
  7444.     move.l    #MODE_NEWFILE,d2
  7445.     jsr    _LVOOpen(a6)
  7446.     move.l    d0,d4
  7447.     beq.s    .C
  7448.     move.l    d4,d1
  7449.     move.l    d5,d2
  7450.     move.l    d6,d3
  7451.     sub.l    d2,d3
  7452.     jsr    _LVOWrite(a6)
  7453.     move.l    d4,d1
  7454.     jsr    _LVOClose(a6)
  7455. .C    bsr    raw_on
  7456.     bra    mk_screen
  7457.  
  7458. ck_hkey    cmp.b    morekeys+12(a5),d0    V2.3    help info ?
  7459.     beq.s    .A
  7460.     cmp.b    #$3f,d0        help key ?
  7461.     bne.s    ck_rkey
  7462. .A    move.l    d6,d2
  7463.     sub.l    d5,d2
  7464.     move.l    d2,-(sp)
  7465.     move.l    a4,d0
  7466.     sub.l    d5,d0
  7467.     moveq    #100,d1
  7468.     bsr    mult_32x32
  7469.     move.l    d2,d1
  7470.     bsr    div_32
  7471.     move.w    d0,-(sp)
  7472.     move.l    sp,a1
  7473.     lea    helpmor(pc),a0
  7474.     bsr    new_print
  7475.     addq.l    #6,sp
  7476.     bra    waitabit
  7477.  
  7478. ck_rkey    cmp.b    morekeys+11(a5),d0    V2.3    resized window ?
  7479.     bne.s    unknown_key
  7480.     bsr    GetWinSize
  7481.     move.w    d0,line_count(a5)
  7482.     bra    mk_screen
  7483.  
  7484. unknown_key
  7485.     cmp.b    morekeys+6(a5),d0    quit more ?
  7486.     beq.s    .A
  7487.     cmp.b    #27,d0        ESC key ?
  7488.     bne    waitabit
  7489. .A    btst    #FLcutline,Flags+3(a5)    unknown key to exit !
  7490.     beq.s    .G
  7491.     lea    cutofftx(pc),a1
  7492.     bsr    pr_string
  7493. .G    lea    show_cursor(pc),a1
  7494.     bsr    pr_stringlf
  7495.     tst.l    temp1(a5)
  7496.     bne.s    .F
  7497.     bsr    raw_off
  7498. .F    move.l    temp1(a5),ConsoleSwitch(a5)
  7499.     clr.b    noreview_flag(a5)
  7500.     moveq    #RETURN_OK,d0
  7501.     rts
  7502.  
  7503. find_end_of_line
  7504. .B    cmp.l    d6,a0    check against end
  7505.     bhs.s    .A
  7506.     move.b    (a0)+,d0
  7507.     cmp.b    #LF,d0
  7508.     bne.s    .B
  7509.     lea    -1(a0),a0
  7510. .A    rts
  7511.  
  7512. ** PRINT STRING AT A4 ENDING IN LF
  7513. pr_line    movem.l    d0-d4/a0,-(sp)
  7514.     move.l    d0,d4
  7515.     move.l    a4,d2
  7516.     move.l    outhandle(a5),d1
  7517.     beq.s    .C
  7518.     move.l    a4,a0
  7519.     bsr    find_end_of_line
  7520.     sub.l    a4,a0
  7521.     move.l    a0,d3
  7522.     tst.l    d4
  7523.     beq.s    .A
  7524.     subq.l    #1,d2
  7525.     addq.l    #1,d3
  7526. .A    tst.l    d3
  7527.     beq.s    .C    don't print if 0
  7528.     jsr    _LVOWrite(a6)
  7529. .C    movem.l    (sp)+,d0-d4/a0
  7530.     rts
  7531.  
  7532. GetWinSize
  7533.     move.l    a2,-(sp)
  7534.     lea    askforsize(pc),a1
  7535.     bsr    pr_error
  7536. .B    move.l    stdin(a5),d1
  7537.     beq    cloga
  7538.     lea    tempbuf(a5),a2
  7539.     move.l    a2,d2
  7540.     moveq    #100,d3
  7541.     jsr    _LVORead(a6)    get size of window
  7542.     add.l    d0,a2
  7543.     cmp.b    #"r",-(a2)
  7544.     bne.s    .B
  7545.     moveq    #1,d1
  7546. .C    cmp.b    #";",-(a2)
  7547.     bne.s    .C
  7548.     dbra    d1,.C
  7549.     addq.l    #1,a2
  7550.     move.l    a2,a1
  7551.     bsr    convert_ASCII_to_num
  7552.     tst.l    d0
  7553.     beq.s    .D
  7554.     bpl.s    .E
  7555. .D    moveq    #10,d0
  7556. .E    subq.w    #1,d0
  7557.     move.l    (sp)+,a2
  7558.     rts
  7559.  
  7560. *****************
  7561. *    TYPE    *        Type out ASCII file command    
  7562. *****************
  7563. typez    tst.b    redirect_in(a5)
  7564.     beq.s    .C
  7565.     bsr    readstdin    read from inhandle
  7566.     bra.s    .D
  7567. .C    move.l    parm2(a5),d0
  7568.     beq    too_less_args
  7569.     move.l    d0,a0
  7570.     bsr    readfile    read from file
  7571. .D    bsr    rawh_off    MAKE SURE YOU CAN PRESS SPACE TO HOLD IT
  7572.     move.l    d0,-(sp)    push address
  7573.     move.l    d1,-(sp)    push size
  7574.     move.l    d0,a4    a4=ptr
  7575.     move.l     d0,d6
  7576.     add.l    d1,d6    d6=end addr
  7577. next_scr    bsr    pr_screen
  7578. freef1    move.l    (sp)+,d0
  7579.     move.l    (sp)+,a1
  7580.     bsr    givemem
  7581.     moveq    #RETURN_OK,D0
  7582.     RTS
  7583.  
  7584. ** ENTRY D6=end of file A4=current pos
  7585. pr_screen    bsr    check_c
  7586.     bne    type_break
  7587.     moveq    #0,d0
  7588.     bsr    pr_line
  7589.     bsr    pr_lf
  7590. .B    cmp.l    d6,a4    check against end
  7591.     bhs.s    type_break
  7592.     move.b    (a4)+,d0
  7593.     cmp.b    #LF,d0
  7594.     bne.s    .B
  7595.     bra.s    pr_screen
  7596. type_break
  7597.     moveq    #RETURN_OK,D0
  7598.     rts
  7599.  
  7600. ***********************
  7601. * EXECUTE SCRIPT FILE *
  7602. ***********************
  7603. executez    ;execute AmigaDOS script
  7604.     move.l    parm2(a5),d0
  7605.     beq    too_less_args
  7606.     move.l    d0,a0
  7607.     lea    ZShellName(pc),a1
  7608.     bsr    CheckOpt    look for ZSHELL option
  7609.     beq.s    execzsh
  7610.     bsr    raw_off
  7611.     lea    tempbuf(a5),a0
  7612.     move.l    a0,d1
  7613.     lea    exectx(pc),a1
  7614. .A    move.b    (a1)+,(a0)+    "execute"
  7615.     bne.s    .A
  7616.     move.b    #" ",-1(a0)    space
  7617.     lea    CLIbuf(a5),a1
  7618. .B    move.b    (a1)+,(a0)+    filename & args
  7619.     bne.s    .B
  7620.     move.b    #LF,-1(a0)    linefeed
  7621.     lea    endcltx(pc),a1
  7622. .D    move.b    (a1)+,(a0)+    "endcli"
  7623.     bne.s    .D
  7624.     move.l    thistask(a5),a1
  7625.     move.l    pr_CIS(a1),d2
  7626.     move.l    pr_COS(a1),d3
  7627.     jsr    _LVOExecute(a6)    execute AmigaDOS script
  7628.     moveq    #RETURN_OK,d0
  7629.     rts
  7630.  
  7631. execzsh    tst.b    redirect_in(a5)
  7632.     beq.s    .C
  7633.     bsr    readstdin    read from inhandle
  7634.     bra.s    xz4
  7635. .C    move.l    parm3(a5),d0
  7636.     beq    too_less_args
  7637.     move.l    d0,a0        read from file
  7638. * Execute ZShell script
  7639. xz2    bsr    readfile    A0 pts to filename
  7640. xz4    move.l    d0,a0
  7641.     cmp.l    #$000003f3,(a0)    is it executable ?
  7642.     beq.s    exerr
  7643.     addq.l    #4,sp        kill return address
  7644. xz3    move.l    d0,a0
  7645.     cmp.w    #"/*",(a0)
  7646.     beq.s    xrexx
  7647.     move.l    d1,scsize(a5)
  7648.     move.l    d0,scaddr(a5)
  7649.     move.l    d0,scptr(a5)
  7650.     move.b    #1,scflag(a5)    make shell think text lines are in memory
  7651.     clr.l    mult_comm_ptr(a5)
  7652.     bra    chorus
  7653. exerr    moveq    #RETURN_ERROR,d0
  7654.     rts
  7655. xrexx    move.l    d0,a1        execute AREXX-script
  7656.     move.l    d1,d0
  7657.     bsr    givemem        kill script
  7658.     lea    CLIbuf(a5),a0
  7659.     move.l    parm1(a5),d0
  7660.     beq.s    .A
  7661.     move.l    d0,a1
  7662. .B    move.b    (a1)+,(a0)+    copy rexx-file to CLIbuf
  7663.     bne.s    .B
  7664. .A    lea    rexxtx(pc),a1
  7665.     move.l    a1,parm1(a5)
  7666.     bra    notfound    execute archie3
  7667.  
  7668. *****************
  7669. *    ECHO    *
  7670. *****************
  7671. echoz    lea    parm2(a5),a3
  7672.     move.l    (a3)+,d0
  7673.     beq.s    .B
  7674.     bra.s    .D
  7675. .A    move.l    (a3)+,d0
  7676.     bne.s    .C
  7677. .B    moveq    #RETURN_OK,d0
  7678.     rts
  7679. .C    bsr    pr_space
  7680. .D    bsr    parse_echo
  7681.     bsr    pr_string
  7682.     bra    .A
  7683.  
  7684. parse_echo
  7685.     move.l    a2,-(sp)
  7686.     move.l    d0,a0
  7687.     move.l    a0,a1
  7688.     move.l    a0,a2
  7689.     bra.s    .C
  7690. .B    move.b    d0,(a2)+
  7691. .C    move.b    (a0)+,d0
  7692.     beq.s    .A
  7693.     cmp.b    #$5c,d0 ;\    Ignore Specialchar
  7694.     bne.s    .D
  7695.     move.b    (a0)+,d0
  7696.     bra.s    .B
  7697. .D    cmp.b    #'^',d0        ^-Character
  7698.     bne.s    .B
  7699.     move.b    (a0)+,d0
  7700.     cmp.b    #"*",d0
  7701.     bne.s    .G
  7702.     move.b    #$9b,d0
  7703.     bra.s    .B
  7704. .G    cmp.b    #"$",d0        Number given ?
  7705.     beq.s    .F
  7706.     cmp.b    #"0",d0
  7707.     blo.s    .E
  7708.     cmp.b    #"9",d0
  7709.     bhi.s    .E
  7710. .F    subq.l    #1,a0
  7711.     movem.l    d1/d2/a1,-(sp)
  7712.     move.l    a0,a1
  7713.     bsr    convert_ASCII_to_num
  7714.     lea    -1(a1),a0
  7715.     movem.l    (sp)+,d1/d2/a1
  7716.     cmp.b    #".",(a0)
  7717.     bne.s    .B
  7718.     addq.l    #1,a0
  7719.     bra.s    .B        Number was given
  7720. .E    and.b    #$3f,d0        Control Char
  7721.     bra.s    .B
  7722. .A    clr.b    (a2)+
  7723.     move.l    (sp)+,a2
  7724.     rts
  7725.  
  7726. *****************
  7727. *    CLS    *
  7728. *****************
  7729. clsz    lea    clstx(pc),a1
  7730.     bsr    pr_string
  7731.     moveq    #RETURN_OK,d0
  7732.     rts
  7733.  
  7734. ** MEM INFO :RETURN 3 LONGWORDS AT A0 -> FREE CHIP,FAST,TOTAL
  7735. memory_info
  7736.     movem.l    a0-a2/a6,-(sp)
  7737.     move.l    a0,a2
  7738.     move.l    4.w,a6
  7739.     jsr    _LVOForbid(a6)    ; don't let 'em change while we ask
  7740.     move.l    #MEMF_CHIP,d1    ; ok, check free chip
  7741.     jsr    _LVOAvailMem(a6)    ; ask system how much there is
  7742.     move.l    d0,(a2)
  7743.     move.l    #MEMF_FAST,d1    ; check fast mem avail
  7744.     jsr    _LVOAvailMem(a6)
  7745.     move.l    d0,4(a2)
  7746.     move.l    #MEMF_PUBLIC,d1     ; get all available memory
  7747.     jsr    _LVOAvailMem(a6)
  7748.     move.l    d0,8(a2)
  7749.     jsr    _LVOPermit(a6)
  7750.     movem.l    (sp)+,a0-a2/a6
  7751.     rts
  7752.  
  7753. *****************
  7754. *    AVAIL    *
  7755. *****************
  7756. availz    tst.l    parm2(a5)
  7757.     beq.s    .A
  7758.     move.l    parm2(a5),a0
  7759.     bsr    return_dash_option
  7760.     cmp.b    #'C',d0
  7761.     bne.s    .A
  7762.     bsr    giveman        free some memory
  7763.     bsr    FreeFNC
  7764.     move.l    4.w,a6
  7765.     moveq    #-1,d0        Free mem
  7766.     move.l    #$00002711,d1    MAGIC NUMBER (from FIDO-net)
  7767.     jsr    _LVOAllocMem(a6)
  7768.     jsr    _LVOForbid(a6)
  7769.     movea.l    a6,a0
  7770.     moveq    #72,d0
  7771.     add.l    d0,a0
  7772.     moveq    #15,d0        free 16 interrupts
  7773.     moveq    #-1,d1
  7774.     moveq    #12,d2
  7775. .B    add.l    d2,a0
  7776.     cmp.l    (a0),d1
  7777.     bne.s    .C
  7778.     cmp.l    4(a0),d1
  7779.     bne.s    .C
  7780.     clr.l    (a0)
  7781.     clr.l    4(a0)
  7782. .C    dbra    d0,.B
  7783.     jsr    _LVOPermit(a6)
  7784.     move.l    dosbase(a5),a6
  7785. .A    lea    -12(sp),sp    show mem
  7786.     lea    (sp),a0
  7787.     bsr    memory_info
  7788.     move.l    a0,a1
  7789.     lea    memess(pc),a0
  7790.     bsr    new_print    show memory
  7791.     lea    12(sp),sp
  7792.     moveq    #RETURN_OK,d0
  7793.     rts
  7794.  
  7795.  
  7796. * ALTER WINDOW PTR FOR THIS PROCESS. USE TO DISABLE REQUESTERS POPPING UP.
  7797. * ENTRY D1=0 (NORMAL)  D1=-1 (SUBNORMAL, no requesters).
  7798. changeWindowPtr
  7799.     movem.l    d1/a0,-(sp)
  7800.     tst.l    d1
  7801.     bne.s    .A
  7802.     move.l    windowptr(a5),d1
  7803. .A    move.l    thistask(a5),a0
  7804.     move.l    d1,pr_WindowPtr(a0)
  7805.     movem.l    (sp)+,d1/a0
  7806.     rts
  7807.  
  7808. raw_on    movem.l    d6/d7,-(sp)    switch console to raw mode
  7809.     btst    #FLhide,Flags+2(a5)
  7810.     beq.s    .A
  7811.     tst.b    redirect_out(a5)
  7812.     bne.s    .A
  7813.     lea    show_cursor(pc),a1
  7814.     bsr    pr_string
  7815. .A    moveq    #-1,d6
  7816.     bra.s    raw_switch
  7817.  
  7818. rawh_off    movem.l    d6/d7,-(sp)    like raw_off,but hides the cursor
  7819.     btst    #FLhide,Flags+2(a5)
  7820.     beq.s    .A
  7821.     tst.b    redirect_out(a5)
  7822.     bne.s    .A
  7823.     lea    hide_cursor(pc),a1
  7824.     bsr    pr_string
  7825. .A    moveq    #0,d6
  7826.     bra.s    raw_switch
  7827.  
  7828. raw_off    movem.l    d6/d7,-(sp)    switch console to normal mode
  7829.     moveq    #0,d6
  7830. ;    bra.s    raw_switch
  7831.  
  7832. *WINDOW TYPE CHANGER    
  7833. raw_switch
  7834.     move.l    ConsoleSwitch(a5),d7
  7835.     beq.s    .A
  7836.     move.l    d7,packettask(a5)
  7837.     bsr    clearArgs
  7838.     move.l    #ACTION_SCREEN_MODE,packettype(a5)
  7839.     move.l    d6,myArg1(a5)
  7840.     bsr    sendpacket
  7841. .A    movem.l    (sp)+,d6/d7
  7842.     rts
  7843.  
  7844. clearArgs movem.l    d0/a0,-(sp)
  7845.     lea    sp_node(a5),a0
  7846.     moveq    #16,d0    ;68bytes
  7847. .A    clr.l    (a0)+
  7848.     dbra    d0,.A
  7849.     movem.l    (sp)+,d0/a0
  7850.     rts
  7851.     
  7852. ** ENTRY Uses myArg1-myArg7, and packettask, packettype
  7853. sendpacket    tst.l    packettask(a5)
  7854.     beq.s    .A
  7855.     movem.l    d0-d1/a0-a2,-(sp)    V2.0 (new written)
  7856.     bsr    sendpacket2
  7857.     move.l    a2,a0
  7858.     jsr    _LVOWaitPort(a6)
  7859.     move.l    a2,a0
  7860.     jsr    _LVOGetMsg(a6)
  7861.     move.l    dosbase(a5),a6
  7862.     movem.l    (sp)+,d0-d1/a0-a2
  7863. .A    rts
  7864.  
  7865. sendpacket2    ;used by sendpacket and get_one_char
  7866.     move.l    4.w,a6
  7867.     move.b    #5,LN_TYPE+sp_node(a5)    message
  7868.     move.l    thistask(a5),a2
  7869.     lea    pr_MsgPort(a2),a2    Process-MsgPort !
  7870.     move.l    a2,sp_reply(a5)        Replyport
  7871.     move.l    a2,sp_port(a5)
  7872.     move.w    #dp_SIZEOF+4,sp_length(a5)
  7873.     lea    sp_link(a5),a0
  7874. ;    move.l    a0,sp_ptr(a5)
  7875.     move.l    a0,LN_NAME+sp_node(a5)    points to link
  7876.     lea    sp_node(a5),a1
  7877.     move.l    a1,sp_link(a5)        linked to itself
  7878.     move.l    packettask(a5),a0
  7879.     jsr    _LVOPutMsg(a6)
  7880.     rts
  7881.  
  7882. *************************
  7883. *    RELABEL     *
  7884. *************************
  7885. relabelz    tst.l    parm3(a5)
  7886.     beq    too_less_args
  7887.     move.l    parm2(a5),a0
  7888.     bsr    check_for_colon
  7889.     bne    no_col
  7890. .D    move.l    parm2(a5),d1    PARM2=DF0: etc
  7891.     jsr    _LVODeviceProc(a6)
  7892.     tst.l    d0
  7893.     beq    DOSerr
  7894.     move.l    d0,packettask(a5)
  7895.     move.l    #256,d0
  7896.     moveq    #1,d1
  7897.     bsr    iwantmem        ASSUME GETS 256 BYTES
  7898.     beq    DOSerr
  7899.     move.l    d0,a2        A2=destination
  7900.     lsr.l    #2,d0
  7901.     bsr    clearArgs
  7902.     move.l    d0,myArg1(a5)    BPTR to my string
  7903.     move.l    parm3(a5),a0    NewName
  7904.     lea    1(a2),a1        A1=after count
  7905.     moveq    #0,d0
  7906. .A    move.b    (a0)+,(a1)+
  7907.     addq.l    #1,d0
  7908.     cmp.b    #':',(a0)        ALLOW FOR IDIOTS WHO PUT : ON END
  7909.     beq.s    .C
  7910.     tst.b    (a0)
  7911.     bne.s    .A
  7912. .C    clr.b    (a1)
  7913.     move.b    d0,(a2)
  7914.     moveq    #ACTION_RENAME_DISK,d0
  7915.     move.l    d0,packettype(a5)    TYPE=RENAME_DISK
  7916.     bsr    sendpacket
  7917.     move.l    a2,a1
  7918.     move.l    #256,d0
  7919.     bsr    givemem
  7920.     bsr    changedisk    ;(moved to dc)
  7921. *    bsr    eval_CD        -IS MORE ELEGANT IF I LEAVE OUT.
  7922.     moveq    #RETURN_OK,d0    USER WILL HAVE TO TYPE CD TO CHANGE
  7923.     rts            PROPER.
  7924.  
  7925. *************************
  7926. *    ADDBUFFERS    *
  7927. *************************
  7928. addbuffersz
  7929.     cmp.w    #36,kickver(a5)
  7930.     blo.s    .A
  7931.     move.l    parm2(a5),d3
  7932.     beq    too_less_args
  7933.     move.l    parm3(a5),d0
  7934.     beq.s    .B
  7935.     move.l    d0,a1
  7936.     bsr    convert_ASCII_to_num
  7937.     beq    bad_number_error
  7938. .B    move.l    d3,d1
  7939.     move.l    d0,d2
  7940.     jsr    _LVOAddBuffers(a6)
  7941.     tst.l    d0
  7942.     beq    DOSerr
  7943.     moveq    #-1,d1
  7944.     cmp.l    d1,d0
  7945.     bne.s    .C
  7946.     jsr    _LVOIoErr(a6)
  7947. .C    move.l    d0,-(sp)
  7948.     move.l    d3,-(sp)
  7949.     lea    (sp),a1
  7950.     lea    addbufftx(pc),a0
  7951.     bsr    new_print
  7952.     addq.l    #8,sp
  7953.     bra.s    .D
  7954.  
  7955. .A    tst.l    parm3(a5)
  7956.     beq    too_less_args
  7957.     bsr    clearArgs
  7958.     move.l    parm3(a5),a1
  7959.     bsr    convert_ASCII_to_num
  7960.     beq    bad_number_error
  7961.     cmp.l    #32767,d0
  7962.     bhi    bad_number_error
  7963.     move.l    d0,myArg1(a5)
  7964.     move.l    parm2(a5),d1    PARM2=DF0: etc
  7965.     jsr    _LVODeviceProc(a6)
  7966.     tst.l    d0
  7967.     beq    DOSerr
  7968.     move.l    d0,packettask(a5)
  7969.     moveq    #ACTION_MORE_CACHE,d0
  7970.     move.l    d0,packettype(A5)
  7971.     bsr    sendpacket
  7972.     bsr    PKTerr
  7973. .D    moveq    #RETURN_OK,d0
  7974.     rts
  7975.  
  7976. *************************
  7977. *    KILL    *
  7978. *************************
  7979. killz    move.l    parm2(a5),d1
  7980.     beq    too_less_args
  7981.     move.l    d1,a0
  7982.     bsr    check_for_colon
  7983.     bne.s    .A
  7984.     bsr    clearArgs    kill filesystemhandler
  7985.     jsr    _LVODeviceProc(a6)    PARM2=DF0: etc
  7986.     tst.l    d0
  7987.     beq    DOSerr
  7988.     move.l    d0,packettask(a5)
  7989.     moveq    #ACTION_DIE,d0
  7990.     move.l    d0,packettype(A5)
  7991.     bsr    sendpacket
  7992.     bsr    PKTerr
  7993. .B    moveq    #RETURN_OK,d0
  7994.     rts
  7995.  
  7996. .A    move.l    d1,a2        kill task or cli-process
  7997.     bsr    findtsk
  7998.     beq.s    .B
  7999.     move.l    a0,a2
  8000.     move.l    pr_CIS(a2),d1
  8001.     beq.s    .C
  8002.     jsr    _LVOClose(a6)
  8003. .C    move.l    pr_COS(a2),d1
  8004.     beq.s    .D
  8005.     jsr    _LVOClose(a6)
  8006.     moveq    #25,d1
  8007.     jsr    _LVODelay(a6)
  8008. .D    move.l    4.w,a6
  8009.     jsr    _LVOForbid(a6)
  8010.     move.l    a2,a1
  8011.     jsr    _LVORemTask(a6)
  8012.     jsr    _LVOPermit(a6)
  8013.     move.l    dosbase(a5),a6
  8014.     bra.s    .B
  8015.  
  8016. *************************
  8017. *    SETDATE        *
  8018. *************************
  8019. setdatez tst.l    parm2(a5)
  8020.     beq    too_less_args
  8021.     move.l    parm2(a5),a2
  8022.     bsr    clearArgs
  8023.     lea    date_mark(a5),a0
  8024.     lea    (a0),a3
  8025.     move.l    a0,myArg4(a5)    ;APTR datestamp
  8026.     bsr    get_time
  8027.     tst.l    parm3(a5)
  8028.     beq    nospda
  8029.     move.l    a2,d1
  8030.     moveq    #ACCESS_READ,d2
  8031.     jsr    _LVOLock(a6)
  8032.     move.l    d0,d7
  8033.     beq    DOSerr
  8034.     bsr    fibexam2
  8035.     move.l    d7,d1
  8036.     jsr    _LVOUnLock(a6)
  8037.     lea    -14(sp),sp
  8038.     lea    (sp),a0
  8039.     lea    fib_Date(a5),a1
  8040.     bsr    convert_time
  8041.     lea    parm3(a5),a0
  8042.     lea    (sp),a1
  8043.     bsr    settime
  8044.     move.w    12(sp),d1
  8045.     lea    14(sp),sp
  8046.     tst.l    d0
  8047.     beq    .B
  8048.     rts
  8049.  
  8050. .B    lea    (a3),a0
  8051.     move.l    d5,(a0)+    ;days
  8052.     divu    #60,d6
  8053.     move.w    d6,d0
  8054.     ext.l    d0
  8055.     move.l    d0,(a0)+    ;mins
  8056.     swap    d6
  8057.     mulu    #50,d6
  8058.     add.l    d1,d6
  8059.     move.l    d6,(a0)        ;ticks
  8060. nospda    move.l    a2,d1    ;filename
  8061.     jsr    _LVODeviceProc(a6)
  8062.     tst.l    d0
  8063.     beq    DOSerr
  8064.     move.l    d0,packettask(a5)
  8065.     move.l    a2,a0
  8066.     lea    temp2buf(a5),a1
  8067.     move.l    a1,a3
  8068.     bsr    split_wild    No wildcard ! Only separates filename !
  8069.     move.l    a2,d1
  8070.     moveq    #ACCESS_READ,d2
  8071.     jsr    _LVOLock(a6)
  8072.     move.l    d0,d7
  8073.     beq    DOSerr
  8074.     move.l    d0,myArg2(a5)    ;BPTR lock
  8075.     move.l    a3,a0
  8076.     lea    tempbuf(a5),a1
  8077.     moveq    #-1,d0
  8078.     bsr    cpBSTR
  8079.     move.l    d0,myArg3(a5)    ;BSTR filename
  8080.     moveq    #ACTION_SET_DATE,d0
  8081.     move.l    d0,packettype(A5)
  8082.     bsr    sendpacket
  8083.     move.l    d7,d1
  8084.     jsr    _LVOUnLock(a6)
  8085.     bsr    PKTerr
  8086.     moveq    #RETURN_OK,d0
  8087.     rts
  8088.  
  8089. *************************
  8090. *    DISKCHANGE    *
  8091. *************************
  8092. diskchangez
  8093.     tst.l    parm2(a5)
  8094.     beq    too_less_args
  8095.     move.l    parm2(a5),d1    PARM2=DF0: etc
  8096.     jsr    _LVODeviceProc(a6)
  8097.     tst.l    d0
  8098.     beq    DOSerr
  8099.     move.l    d0,packettask(a5)
  8100.     bsr    changedisk
  8101.     moveq    #RETURN_OK,d0
  8102.     rts
  8103.  
  8104. ** USES task in packettask
  8105. changedisk
  8106.     bsr    clearArgs
  8107.     moveq    #ACTION_INHIBIT,d0
  8108.     move.l    d0,packettype(a5)
  8109.     moveq    #-1,d0    ;1?
  8110.     move.l    d0,myArg1(a5)
  8111.     bsr    sendpacket
  8112.     bsr    PKTerr
  8113.     clr.l    myArg1(a5)
  8114.     bsr    sendpacket
  8115.     bsr    PKTerr
  8116.     rts
  8117.  
  8118. *************************
  8119. *    LOCK        *
  8120. *************************
  8121. lockz    move.l    parm3(a5),a0
  8122.     moveq    #-1,d7
  8123.     bsr    CheckOnOff
  8124.     bne.s    .B
  8125.     moveq    #0,d7
  8126. .B    move.l    parm2(a5),d1    PARM2=DF0: etc
  8127.     beq    too_less_args
  8128.     jsr    _LVODeviceProc(a6)
  8129.     tst.l    d0
  8130.     beq    DOSerr
  8131.     move.l    d0,packettask(a5)
  8132.     bsr    clearArgs
  8133.     move.l    #ACTION_WRITE_PROTECT,d0
  8134.     move.l    d0,packettype(a5)
  8135.     move.l    d7,myArg1(a5)
  8136.     bsr    sendpacket
  8137.     bsr    PKTerr
  8138.     moveq    #RETURN_OK,d0
  8139.     rts
  8140.  
  8141. *********************************
  8142. *    UNSET VARIABLE        *
  8143. *********************************
  8144. unsetz    lea    parm2(a5),a3
  8145.     move.l    (a3)+,d0
  8146.     bne.s    .A
  8147.     bsr    deallocate_sets
  8148.     bra.s    .B
  8149. .A    move.l    d0,a0
  8150.     bsr    check_if_set_already_there
  8151.     tst.l    d0
  8152.     beq    unset_failure
  8153.     move.l    d0,a1
  8154.     move.l    (a1),d2    GRAB NEXT SET POINTER
  8155.     move.l    set_size(a1),d0
  8156.     move.l    d1,a0    D1=prior set
  8157.     move.l    d2,(a0)    SKIP OVER SET TO DELETE
  8158.     bsr    givemem
  8159.     move.l    (a3)+,d0
  8160.     bne.s    .A
  8161. .B    moveq    #RETURN_OK,d0
  8162.     rts
  8163. unset_failure
  8164.     lea    temp2buf(a5),a2
  8165. pr_notfound    ;string in a2
  8166.     move.l    a2,a1
  8167.     bsr    pr_string
  8168.     lea    notfund(pc),a1
  8169.     bsr    pr_stringlf
  8170.     moveq    #RETURN_ERROR,d0
  8171.     rts
  8172.  
  8173. *********************************
  8174. *    SET VARIABLE KEY    *
  8175. *********************************
  8176. set_link    equ    0
  8177. set_size    equ    4
  8178. set_name    equ    8
  8179. set_defn    equ    24
  8180.  
  8181. set_funcz
  8182.     move.l    parm2(a5),d0        SEE IF ANY PARAMETERS TYPED
  8183.     beq.s    show_current_sets
  8184.     move.l    parm3(a5),d1
  8185.     beq    too_less_args
  8186.     move.l    d0,a0        A0=parm2
  8187.     move.l    d1,a1
  8188.     bsr    compare_strings
  8189.     bne.s    .A
  8190.     move.l    #210,d0
  8191.     bra    resi_error
  8192. .A    bsr    check_if_set_already_there
  8193.     tst.l    d0
  8194.     beq    create_new_set
  8195.     movem.l    a0-a1,-(sp)    update old set
  8196.     move.l    d0,a1        first delete old one
  8197.     move.l    (a1),d2    GRAB NEXT SET POINTER
  8198.     move.l    set_size(a1),d0
  8199.     move.l    d1,a0        D1=prior set
  8200.     move.l    d2,(a0)    SKIP OVER SET TO DELETE
  8201.     bsr    givemem
  8202.     movem.l    (sp)+,a0-a1     and replace with new set
  8203.     bra    create_new_set
  8204.  
  8205. show_current_sets
  8206.     bsr    rawh_off
  8207.     move.l    first_set_defn(a5),d0
  8208.     beq    no_sets_to_show
  8209. show_next_set
  8210.     move.l    d0,a3
  8211.     lea    set_name(a3),a1
  8212.     bsr    pr_string
  8213.     bsr    pr_tab
  8214.     lea    set_defn(a3),a1
  8215.     bsr    pr_stringlf
  8216.     move.l    (a3),d0        CHECK NEXT SET ADDRESS
  8217.     bne    show_next_set
  8218. no_sets_to_show
  8219.     moveq    #RETURN_OK,d0
  8220.     rts
  8221.  
  8222. create_new_set        ;a0=name a1=def
  8223.     lea    tempbuf(a5),a3        GET BIG BLOCK
  8224.     lea    set_name(a3),a1
  8225.     bsr    cp_string        COPY SET NAME TO SPACE
  8226.     bsr    ConvertSemi
  8227.     lea    CLIbuf(a5),a0    use CLIbuf, end in a1
  8228. .D    move.b    (a0)+,d0
  8229.     beq.s    .C
  8230.     cmp.b    #" ",d0        search for space
  8231.     bne.s    .D
  8232. .E    move.b    (a0)+,d0
  8233.     cmp.b    #" ",d0        check multiple spaces
  8234.     beq.s    .E
  8235.     cmp.b    #$22,-1(a0)    check for "
  8236.     bne.s    .G
  8237.     cmp.b    #$22,-2(a1)    surrounded by " " ?
  8238.     bne.s    .G
  8239.     clr.b    -2(a1)
  8240.     addq.l    #1,a0
  8241. .G    lea    set_defn(a3),a1    store definition
  8242. .C    subq.l    #1,a0
  8243. .F    move.b    (a0)+,(a1)+
  8244.     bne.s    .F
  8245.     move.l    a1,d4        D4=after end
  8246.     sub.l    a3,a1        WORK OUT HOW BIG IS ACTUALLY
  8247.     move.l    a1,d0
  8248.     moveq    #1,d1
  8249.     bsr    iwantmem    allocate block big enough for everything
  8250.     beq    DOSerr
  8251.     move.l    d0,a2
  8252.     move.l    a1,set_size(a2)
  8253.     move.l    first_set_defn(a5),d1
  8254.     move.l    d1,(a2)            new pts to old
  8255.     move.l    a2,first_set_defn(a5)
  8256.     lea    set_name(a2),a1    new block
  8257.     lea    set_name(a3),a0    temp block
  8258. .B    move.b    (a0)+,(a1)+
  8259.     cmp.l    a0,d4
  8260.     bne.s    .B
  8261.     moveq    #RETURN_OK,d0
  8262.     rts
  8263.  
  8264. check_if_set_already_there
  8265. * A0= set name
  8266.     movem.l    a0-a1,-(sp)
  8267.     lea    temp2buf(a5),a1
  8268.     bsr    cp_string
  8269.     bsr    search_sets
  8270.     movem.l    (sp)+,a0-a1
  8271.     rts
  8272.  
  8273. deallocate_sets
  8274.     move.l    first_set_defn(a5),d3
  8275.     beq    no_sets_to_lose
  8276. lose_next_set
  8277.     move.l    d3,a1
  8278.     move.l    (a1),-(sp)
  8279.     move.l    set_size(a1),d0
  8280.     bsr    givemem
  8281.     move.l    (sp)+,d3
  8282.     bne    lose_next_set
  8283.     clr.l    first_set_defn(a5)
  8284. no_sets_to_lose
  8285.     rts
  8286.  
  8287. ConvertSemi    ;convert \; into ; from/to CLIbuf
  8288.     lea    CLIbuf(a5),a0
  8289.     move.l    a0,a1
  8290.     moveq    #0,d1
  8291. .A    move.b    (a0)+,d0
  8292.     cmp.b    #$5c,d1    ;\
  8293.     bne.s    .D
  8294.     cmp.b    #";",d0
  8295.     beq.s    .C
  8296.     cmp.b    #"|",d0
  8297.     bne.s    .D
  8298. .C    subq.l    #1,a1
  8299. .D    move.b    d0,(a1)+
  8300.     move.b    d0,d1
  8301.     bne.s    .A
  8302.     rts
  8303.  
  8304. *************************
  8305. *    RESIDENT    *    V2.0:uses the GLOBAL resident-list
  8306. *************************    (many things changed)
  8307. residentz    move.l    parm2(a5),d0    SEE IF ANY PARAMETERS TYPED
  8308.     beq    show_current_residents
  8309.     lea    parm2(a5),a3
  8310.     move.l    (a3),a0
  8311.     bsr    return_dash_option
  8312.     cmp.b    #'C',d0
  8313.     beq    kill_resi
  8314. next_resi    move.l    (a3)+,d0
  8315.     bne.s    .B
  8316.     moveq    #RETURN_OK,d0
  8317.     rts
  8318. .B    move.l    d0,a4        A4=parmName
  8319.     move.l    a3,-(sp)
  8320.     bsr    spaths2        SEARCH PATHS FOR THE COMMAND
  8321.     move.l    (sp)+,a3
  8322.     tst.l    d0
  8323.     beq    resi_not_found
  8324.     move.l    d0,-(sp)    push seglist
  8325.     move.l    a4,a0
  8326.     move.l    a4,a1
  8327.     bsr    rempath        SRC = DEST is OK
  8328.     bsr    search_res2    find if same name is on resi list
  8329.     move.l    (sp)+,d3
  8330.     move.l    d0,d1
  8331.     bne.s    .A
  8332.     bsr    create_resi
  8333.     bra.s    next_resi
  8334. .A    moveq    #1,d0
  8335.     cmp.l    resi_usecount(a0),d0
  8336.     bne.s    resi_inuse
  8337.     move.l    d0,resi_usecount(a0)
  8338.     move.l    d3,resi_seglist(a0)    new seglist
  8339.     jsr    _LVOUnLoadSeg(a6)    Unload old one with same name
  8340.     bra.s    next_resi
  8341.  
  8342. kill_resi    tst.l    (a3)+
  8343. .B    move.l    (a3)+,d0
  8344.     bne.s    .A
  8345.     moveq    #RETURN_OK,d0
  8346.     rts
  8347. .A    move.l    d0,a4
  8348.     move.l    a4,a0
  8349.     move.l    a4,a1
  8350.     bsr    rempath        SRC = DEST is OK
  8351.     bsr    search_res2    find if same name is on resi list
  8352.     move.l    d0,d1        gives d0,a0,d2
  8353.     beq.s    resi_not_found
  8354.     moveq    #1,d0
  8355.     cmp.l    resi_usecount(a0),d0
  8356.     bne.s    resi_inuse
  8357.     move.l    a0,a2
  8358.     move.l    d2,a0
  8359.     move.l    resi_link(a2),resi_link(a0)
  8360.     clr.l    resi_link(a2)
  8361.     jsr    _LVOUnLoadSeg(a6)    Unload old one with same name
  8362.     move.l    a2,d1
  8363.     lsr.l    #2,d1
  8364.     jsr    _LVOUnLoadSeg(a6)
  8365.     bra.s    .B
  8366.  
  8367. resi_not_found
  8368.     move.l    #205,d0
  8369.     bra.s    resi_error
  8370. resi_no_mem
  8371.     moveq    #103,d0
  8372.     bra.s    resi_error
  8373. resi_inuse
  8374.     move.l    #202,d0
  8375. resi_error
  8376.     move.l    dosbase(a5),a6
  8377.     bra    pr_galactic
  8378.  
  8379. create_resi        ;D3:SegList, A4:Name
  8380.     moveq    #resi_length,d0
  8381.     move.l    a4,a0
  8382. .A    addq.l    #1,d0    one more for lenght-byte
  8383.     tst.b    (a0)+
  8384.     bne.s    .A
  8385.     addq.l    #4,d0    4 more for segment-length
  8386.     addq.l    #7,d0    (7 more for and'ing needed by UnLoadSeg)
  8387.     moveq    #-4,d1
  8388.     and.l    d1,d0
  8389.     move.l    d0,d2
  8390.     moveq    #1,d1
  8391.     bsr    iwantmem
  8392.     beq.s    resi_no_mem
  8393.     addq.l    #4,d0
  8394.     move.l    d0,a2        D0=addr of resi_list_node
  8395.     move.l    d2,-4(a2)    save segment-length
  8396.     bsr    do_forbid
  8397.     bsr    resi_hand
  8398.     move.l    d0,resi_link(a2)
  8399.     move.l    a2,d0
  8400.     lsr.l    #2,d0
  8401.     move.l    d0,(a0)
  8402.     moveq    #1,d0
  8403.     move.l    d0,resi_usecount(a2)
  8404.     move.l    d3,resi_seglist(a2)
  8405.     lea    resi_name(a2),a1
  8406.     move.l    a4,a0
  8407.     moveq    #-1,d0
  8408.     bsr    cpBSTR
  8409.     bsr    do_permit
  8410.     moveq    #0,d0
  8411.     rts
  8412.  
  8413. resi_hand    move.l    dl_Root(a6),a0
  8414.     move.l    rn_Info(a0),a0
  8415.     add.l    a0,a0
  8416.     add.l    a0,a0
  8417.     lea    di_NetHand(a0),a0    NetHand in A0
  8418.     move.l    (a0),d0        Start of Resi-List in D0
  8419.     rts
  8420.  
  8421. show_current_residents
  8422.     lea    residetx(pc),a1
  8423.     bsr    pr_stringlf
  8424.     bsr    rawh_off
  8425.     bsr    resi_hand
  8426.     beq    no_resis_to_show
  8427. .A    lsl.l    #2,d0
  8428.     move.l    d0,a3
  8429.     move.l    resi_usecount(a3),d0
  8430.     subq.l    #1,d0
  8431.     bsr    print10
  8432.     bsr    pr_space
  8433. ;    move.l    a3,d0
  8434. ;    bsr    printADR
  8435. ;    bsr    pr_space
  8436.     lea    resi_name(a3),a1
  8437.     moveq    #0,d3
  8438.     move.b    (a1)+,d3
  8439.     move.l    a1,d2
  8440.     move.l    outhandle(a5),d1
  8441.     beq.s    .B
  8442.     jsr    _LVOWrite(a6)
  8443.     bsr    pr_lf
  8444. .B    bsr    check_c
  8445.     bne.s    no_resis_to_show
  8446.     move.l    resi_link(a3),d0
  8447.     bne    .A
  8448. no_resis_to_show
  8449.     moveq    #RETURN_OK,d0
  8450.     rts
  8451.  
  8452. ******    Copy String from A0 to BSTR A1
  8453. cpBSTR    movem.l    d1-d2/a0-a2,-(sp)    max. Length-2 in D0
  8454.     lea    1(a1),a2
  8455.     moveq    #0,d2
  8456.     bra.s    .B
  8457. .A    move.b    d1,(a2)+
  8458.     addq.l    #1,d2
  8459. .B    move.b    (a0)+,d1
  8460.     dbeq    d0,.A
  8461.     clr.b    (a2)    ;NULL-end it
  8462.     move.b    d2,(a1)
  8463.     move.l    a1,d0
  8464.     lsr.l    #2,d0
  8465.     movem.l    (sp)+,d1-d2/a0-a2    D0 is BPTR to the BSTR
  8466.     rts
  8467.  
  8468.  
  8469. *********************************
  8470. *    RPN CALCULATOR        *
  8471. *********************************
  8472. evalz    lea    parm2(a5),a4
  8473.     move.l    sp,d5        remember the stack ptr
  8474. rpn_loop1    move.l    (a4)+,d1
  8475.     beq    show_rpn_result
  8476.     move.l    d1,a1
  8477.     tst.b    1(a1)
  8478.     bne    not_peek32
  8479.     lea    8(sp),a0
  8480.     cmp.l    a0,d5
  8481.     blo    not_poke32
  8482.  
  8483.     cmp.b    #'+',(a1)        +    ADD
  8484.     bne.s    not_add
  8485.     move.l    (sp)+,d0
  8486.     add.l    d0,(sp)
  8487.     bra.s    rpn_loop1
  8488. not_add    cmp.b    #'-',(a1)        -    SUBTRACT
  8489.     bne.s    not_sub
  8490.     move.l    (sp)+,d0
  8491.     sub.l    d0,(sp)
  8492.     bra.s    rpn_loop1
  8493.  
  8494. not_sub    cmp.b    #'*',(a1)        *    MULTIPLY
  8495.     bne.s    not_mult
  8496.     move.l    (sp)+,d0    last
  8497.     move.l    (sp)+,d1    2nd last
  8498.     bsr    mult_32x32
  8499.     move.l    d0,-(sp)
  8500.     bra.s    rpn_loop1
  8501. not_mult    cmp.b    #'/',(a1)    /    DIVIDE
  8502.     bne.s    not_div
  8503.     move.l    (sp)+,d1    last
  8504.     move.l    (sp)+,d0    2nd last
  8505.     tst.l    d1
  8506.     beq.s    rpn_error    no divide by zero
  8507.     bsr    div_32
  8508.     move.l    d0,-(sp)
  8509.     bra.s    rpn_loop1
  8510.  
  8511. not_div    cmp.b    #'&',(a1)        &    AND
  8512.     bne.s    not_and
  8513.     move.l    (sp)+,d0
  8514.     and.l    d0,(sp)
  8515. rpn_lp1    bra.s    rpn_loop1
  8516. not_and    cmp.b    #"!",(a1)        !    OR
  8517.     bne.s    not_or
  8518.     move.l    (sp)+,d0
  8519.     or.l    d0,(sp)
  8520.     bra.s    rpn_lp1
  8521. not_or    cmp.b    #'=',(a1)        =    POKE
  8522.     bne.s    not_poke32
  8523.     move.l    (sp)+,d1    get value
  8524.     move.l    (sp)+,d0    get addr
  8525.     and.b    #$fe,d0
  8526.     move.l    d0,a0
  8527.     move.l    (a0),-(sp)    peek it
  8528.     move.l    d1,(a0)        poke it
  8529.     bra.s    rpn_lp1
  8530. not_poke32
  8531.     cmp.b    #'?',(a1)        ?    PEEK
  8532.     bne.s    not_peek32
  8533.     move.l    (sp)+,d0    get addr
  8534.     cmp.l    sp,d5
  8535.     blo.s    rpn_error
  8536.     and.b    #$fe,d0
  8537.     move.l    d0,a0
  8538.     move.l    (a0),-(sp)
  8539.     bra.s    rpn_lp1
  8540.  
  8541. not_peek32
  8542.     bsr    convert_ASCII_to_num
  8543.     beq.s    rpn_error2
  8544.     move.l    d0,-(sp)
  8545.     bra.s    rpn_lp1
  8546. rpn_error2
  8547.     moveq    #115,d0
  8548.     bra.s    rpn_error1
  8549. rpn_error
  8550.     moveq    #-119,d0
  8551. rpn_error1
  8552.     move.l    d5,sp
  8553.     bsr    pr_DOSerr
  8554.     moveq    #RETURN_ERROR,d0
  8555.     rts
  8556.  
  8557. show_rpn_result
  8558.     lea    4(sp),a0
  8559.     cmp.l    a0,d5
  8560.     bne    rpn_error
  8561.     move.l    (sp),-(sp)        have result twice
  8562.     moveq    #RETURN_ERROR,d7    error on equal
  8563.     tst.l    (sp)
  8564.     beq.s    .B
  8565.     bpl.s    .C
  8566.     moveq    #RETURN_WARN,d7        warn on minus
  8567.     bra.s    .B
  8568. .C    moveq    #RETURN_OK,d7        ok on plus
  8569. .B    move.l    sp,a1
  8570.     lea    rpn_result_tx(pc),a0    print hex & dec
  8571.     tst.b    redirect_out(a5)    output redirected ?
  8572.     beq.s    .A
  8573.     moveq    #RETURN_OK,d7
  8574.     lea    rpn_res2(pc),a0    print only number
  8575. .A    bsr    new_print
  8576.     move.l    d5,sp
  8577.     move.l    d7,d0
  8578.     rts
  8579.  
  8580. div_32    movem.l    d2-d4,-(sp)    ;d0=d0/d1
  8581.     moveq    #0,d2
  8582.     moveq    #31,d4
  8583. _divu1    roxl.l    #1,d0    ; divident
  8584.     roxl.l    #1,d2    ; work accum
  8585.     cmp.l    d1,d2    ; cmp with divisor
  8586.     blo.s    _divu2
  8587.     sub.l    d1,d2
  8588.     dc.l    $003c0010    ;ori.b    #16,CCR    ;setx
  8589. _divu2    roxl.l    #1,d3    ; result
  8590.     dbf    d4,_divu1
  8591.     move.l    d3,d0
  8592.     move.l    d2,d1
  8593.     movem.l    (sp)+,d2-d4    ;result:d0 rest:d1
  8594.     rts
  8595.  
  8596.  
  8597. mult_32x32
  8598. * D1 = 32 bit, D0 = 32 bit (result)
  8599.     movem.l    d1-d3,-(sp)
  8600.     move.l    d0,d2
  8601.     move.l    d0,d3
  8602.     mulu    d1,d0    save intermediate result
  8603.     swap    d3
  8604.     mulu    d1,d3
  8605.     swap    d3
  8606.     clr.w    d3
  8607.     add.l    d3,d0
  8608.     swap    d1
  8609.     mulu    d1,d2
  8610.     swap    d2
  8611.     clr.w    d2
  8612.     add.l    d2,d0
  8613.     movem.l    (sp)+,d1-d3
  8614.     rts
  8615.  
  8616. * Convert null ending ASCII number(A1) to 32bit number in D0
  8617. * Return D1=0 if bad number (a1:current pos)
  8618. convert_ASCII_to_num    
  8619.     movem.l    d2/d3/a0,-(sp)
  8620.     moveq    #0,d3    SET POSITIVE
  8621.     moveq    #0,d1    RESET BASE
  8622. .A    cmp.b    #'^',(a1)
  8623.     bne.s    convnor
  8624.     lea    1(a1),a0
  8625.     bsr    readfile
  8626.     cmp.w    #NEWPRINTSIZE-2,d1
  8627.     bhs    conversion_finished
  8628.     move.l    d0,a0
  8629.     lea    NewPrintBuffer(a5),a1
  8630.     move.l    d1,d2
  8631.     subq.w    #1,d2
  8632. .B    move.b    (a0)+,(a1)+
  8633.     dbra    d2,.B
  8634.     clr.b    (a1)
  8635.     move.l    d0,a1
  8636.     move.l    d1,d0
  8637.     bsr    givemem
  8638.     lea    NewPrintBuffer(a5),a1
  8639. ;    bset    #0,d3
  8640.     bra.s    .A
  8641. convnor    moveq    #0,d0    RESET RESULT
  8642.     moveq    #0,d1    RESET BASE
  8643.     tst.b    (a1)
  8644.     beq    conversion_finished
  8645.     moveq    #LF,d1    SET THE BASE
  8646.     cmp.b    #'-',(a1)    negative sign
  8647.     bne.s    .A
  8648.     bset    #3,d3
  8649. .D    addq.l    #1,a1
  8650. .A    cmp.b    #'+',(a1)    positive sign
  8651.     beq.s    .D
  8652.     cmp.b    #'&',(a1)    for APTR (hex!) -> BPTR
  8653.     bne.s    .B
  8654.     addq.l    #1,a1
  8655.     bset    #1,d3
  8656.     moveq    #16,d1    SET RADIX16
  8657.     bra    same_base
  8658. .B    cmp.b    #'!',(a1)    for BPTR (hex!) -> APTR
  8659.     bne.s    .C
  8660.     addq.l    #1,a1
  8661.     bset    #2,d3
  8662.     moveq    #16,d1    SET RADIX16
  8663.     bra    same_base
  8664. .C    cmp.b    #'$',(a1)
  8665.     bne.s    other_base
  8666.     move.b    (a1)+,d2    DUMMY BUMP
  8667.     moveq    #16,d1    SET RADIX16
  8668.     bra    same_base
  8669.  
  8670. other_base
  8671.     cmp.b    #'%',(a1)
  8672.     bne.s    same_base
  8673.     move.b    (a1)+,d2
  8674.     moveq    #2,d1    SET RADIX2
  8675. same_base    moveq    #0,d2
  8676.     move.b    (a1)+,d2
  8677.     beq    conversion_finished
  8678.     bsr    convert_D2_to_num
  8679.     tst.l    d1
  8680.     beq.s    conversion_finished
  8681.     bsr    mult_32x32
  8682.     add.l    d2,d0
  8683.     bra    same_base
  8684. conversion_finished
  8685.     btst    #3,d3
  8686.     beq.s    .A
  8687.     neg.l    d0
  8688. .A    btst    #1,d3
  8689.     beq.s    .B
  8690.     lsr.l    #2,d0
  8691. .B    btst    #2,d3
  8692.     beq.s    .C
  8693.     lsl.l    #2,d0
  8694. .C    movem.l    (sp)+,d2/d3/a0
  8695.     tst.b    d1
  8696.     rts
  8697.     
  8698. convert_D2_to_num
  8699.     cmp.b    #'0',d2
  8700.     blo.s    bad_number
  8701.     cmp.b    #'9',d2
  8702.     bhi.s    check_hex
  8703.     sub.b    #'0',d2
  8704.     rts
  8705. check_hex    cmp.b    #16,d1
  8706.     bne.s    bad_number
  8707.     cmp.b    #'f',d2
  8708.     bhi.s    bad_number
  8709.     cmp.b    #'A',d2
  8710.     blo.s    bad_number
  8711.     cmp.b    #'F',d2
  8712.     bhi.s    check_upper_hex
  8713.     sub.b    #55,d2
  8714.     rts
  8715. check_upper_hex
  8716.     cmp.b    #'a',d2
  8717.     blo.s    bad_number
  8718.     sub.b    #87,d2
  8719.     rts
  8720. bad_number
  8721.     moveq    #0,d1    FLAG ERROR thru silly base
  8722.     rts
  8723.  
  8724. *********************************
  8725. *    MEMORY EXAMINE        *
  8726. *********************************
  8727. memexamz    clr.l    mem_offset_addr(a5)
  8728.     moveq    #0,d7
  8729.     tst.l    parm2(a5)        CHECK IF NO ADDRESS.
  8730.     bne.s    .E
  8731.     moveq    #8,d7
  8732.     bra    show_mempage
  8733. .E    bsr    fixpam32
  8734.     tst.b    (a1)
  8735.     beq.s    .A
  8736.     move.l    a0,-(sp)
  8737.     bsr    convert_ASCII_to_num    convert 2nd num
  8738.     move.l    (sp)+,a0
  8739.     tst.b    d1
  8740.     beq    bad_number_error
  8741.     move.l    d0,d7            D7=2nd num
  8742. .A    move.l    a0,a1
  8743.     bsr    convert_ASCII_to_num    convert 1st num
  8744.     beq    bad_number_error
  8745. .C    tst.l    d7
  8746.     bne.s    .D
  8747.     moveq    #8,d7
  8748.     bra.s    memex2
  8749. .D    sub.l    d0,d7
  8750.     lsr.l    #4,d7
  8751.     addq.l    #1,d7
  8752.  
  8753. memex2    move.l    d0,mem_addr(a5)
  8754. show_mempage
  8755.     and.b    #$fe,mem_addr+3(a5)    MAKE SURE EVEN ADDRESS
  8756. shmem2    bsr    check_c
  8757.     bne    .A
  8758.     bsr    show_16_locs
  8759.     subq.l    #1,d7        D7=count
  8760.     bne.s    shmem2
  8761. .A    moveq    #RETURN_OK,d0
  8762.     rts
  8763.     
  8764. show_16_locs
  8765.     move.l    mem_addr(a5),a1
  8766.     lea    CLIbuf(a5),a3
  8767.     move.l    a3,a0
  8768.     moveq    #15,d0
  8769. sh_16_1    move.b    (a1)+,d1
  8770.     move.b    #'.',(a0)+
  8771.     move.b    d1,d2
  8772.     bclr    #7,d2
  8773.     cmp.b    #' ',d2
  8774.     blo.s    sh_16_2
  8775.     move.b    d1,-1(a0)
  8776. sh_16_2    dbra    d0,sh_16_1
  8777.     clr.b    (a0)
  8778.     move.l    a3,-(sp)        PUSH STRING ADDR
  8779.     move.l    -(a1),-(sp)    PUSH LAST BYTES
  8780.     move.l    -(a1),-(sp)
  8781.     move.l    -(a1),-(sp)
  8782.     move.l    -(a1),-(sp)    PUSH FIRST BYTES
  8783.     move.l    mem_addr(a5),d0
  8784.     sub.l    mem_offset_addr(a5),d0
  8785.     move.l    d0,-(sp)
  8786.     lea    mem_line(pc),a0
  8787.     lea    (sp),a1
  8788.     bsr    new_print
  8789.     movem.l    (sp)+,d0-d5    DUMMY
  8790.     add.l    #16,mem_addr(a5)
  8791.     rts
  8792.  
  8793. * ENTRY A0=FORMATSTRING A1=DATASTREAM.
  8794. new_print    ;v2.0 small data
  8795.     movem.l    d0-d3/a0-a3,-(sp)
  8796.     lea    NewPrintBuffer(a5),a3    ;V2.0 not on stack
  8797.     lea    KPutChar(pc),a2
  8798.     move.l    4.w,a6
  8799.     jsr    _LVORawDoFmt(a6)
  8800.     move.l    dosbase(a5),a6
  8801.     move.l    outhandle(a5),d1
  8802.     beq.s    .B
  8803.     lea    NewPrintBuffer(a5),a0
  8804.     move.l    a0,d2
  8805.     moveq    #-1,d3
  8806. .A    addq.l    #1,d3
  8807.     tst.b    (a0)+
  8808.     bne.s    .A
  8809.     jsr    _LVOWrite(a6)
  8810. .B    movem.l    (sp)+,d0-d3/a0-a3
  8811.     rts
  8812.  
  8813. KPutChar move.b    d0,(a3)+
  8814.     rts
  8815.  
  8816. ** SAVE STATS store current time in date mark, and current memory use in mem mark
  8817. save_mem_time
  8818.     movem.l    d0-d1/a0-a1,-(sp)
  8819.     clr.l    temp2(a5)
  8820.     btst    #FLcheck,Flags+3(a5)
  8821.     beq.s    .C
  8822.     move.l    4.w,a0
  8823.     tst.w    296(a0)        CPU better than 68000 ?
  8824.     bne.s    .A
  8825.     move.l    #1024,d0    no, store lower memory
  8826.     moveq    #1,d1
  8827.     bsr    iwantmem
  8828.     move.l    d0,temp2(a5)
  8829.     beq.s    .A
  8830.     move.l    d0,a1
  8831.     sub.l    a0,a0        adress 0 to 1023
  8832.     move.l    #$C0DEDBAD,(a0)    Mungwall does the same
  8833.     move.l    #1024/4-1,d0
  8834. .B    move.l    (a0)+,(a1)+
  8835.     dbra    d0,.B
  8836. .A    lea    mem_mark(a5),a0
  8837.     bsr    memory_info    remember memory usage
  8838. .C    lea    date_mark(a5),a0
  8839.     bsr    get_time    remember this time
  8840.     movem.l    (sp)+,d0-d1/a0-a1
  8841.     rts
  8842.  
  8843. ** DISPLAY TIME ELAPSED SINCE LAST CALL TO SAVE TIME AND
  8844. **  ALSO CHANGE IN MEMORY AVAILABLE. EXPECTS RETURN CODE TO BE ABOVE RETURN
  8845. **  ADDRESS ON STACK ie 4(sp)
  8846. show_status
  8847.     lea    -34(sp),sp
  8848.     lea    (sp),a0        A0=time area
  8849.     move.l    Result2(a5),(a0)+    -4(a0) ioerr-result
  8850.     bsr    get_time    
  8851.     lea    date_mark(a5),a1
  8852.     move.l    ds_Tick(a0),d0
  8853.     sub.l    ds_Tick(a1),d0
  8854.     bpl.s    no_tick_carry
  8855.     add.l    #3000,d0
  8856.     subq.l    #1,ds_Minute(a0)
  8857. no_tick_carry
  8858.     move.l    d0,ds_Tick(a1)    store in datemark
  8859.     move.l    ds_Minute(a0),d0
  8860.     sub.l    ds_Minute(a1),d0
  8861.     move.l    d0,ds_Minute(a1)
  8862.     bsr    convert_time    A0=4+3 words of time
  8863. do_mem_deltas
  8864.     lea    14(a0),a0
  8865.     bsr    memory_info
  8866.     lea    mem_mark(a5),a1
  8867.     move.l    (a1),d0
  8868.     sub.l    d0,(a0)    subtract old from new    ;chip
  8869.     move.l    4(a1),d0
  8870.     sub.l    d0,4(a0)            ;fast
  8871.     move.l    8(a1),d0
  8872.     sub.l    d0,8(a0)            ;total
  8873.     lea    -12(a0),a1
  8874.     move.l    -18(a0),(a1)
  8875.     lea    stat_text(pc),a0
  8876.     bsr    new_print
  8877.     lea    34(sp),sp
  8878.     move.l    temp2(a5),d0    check low memory
  8879.     beq.s    .A
  8880.     move.l    d0,a1        show changes of low memory
  8881.     sub.l    a0,a0
  8882.     move.l    #1024/4-1,d0
  8883. .B    move.l    (a0)+,d1
  8884.     cmp.l    (a1)+,d1
  8885.     beq.s    .C
  8886.     movem.l    a0-a1,-(sp)
  8887.     move.l    -4(a0),-(sp)
  8888.     move.l    -4(a1),-(sp)
  8889.     move.l    a0,-(sp)
  8890.     subq.l    #4,(sp)
  8891.     move.l    sp,a1
  8892.     lea    lowmemtx(pc),a0    print the changes
  8893.     bsr    new_print
  8894.     lea    12(sp),sp
  8895.     movem.l    (sp)+,a0-a1
  8896. .C    dbra    d0,.B
  8897.     move.l    temp2(a5),a1
  8898.     move.l    #1024,d0
  8899.     bsr    givemem
  8900. .A    rts
  8901.  
  8902. *************************    
  8903. *    DATE/TIME    *
  8904. *************************
  8905. datez    lea    date_mark(a5),a2
  8906.     move.l    a2,a0
  8907.     bsr    get_time
  8908.     move.l    a2,a1
  8909.     lea    -14(sp),sp
  8910.     lea    (sp),a0
  8911.     bsr    convert_time
  8912.     tst.l    parm2(a5)
  8913.     beq.s    .A
  8914.     lea    parm2(a5),a0
  8915.     lea    (sp),a1
  8916.     bsr.s    settime
  8917.     lea    14(sp),sp
  8918.     bne.s    .B
  8919.     bsr    tset
  8920.     clr.l    parm2(a5)
  8921.     bra.s    datez    ;now print date/time
  8922. .A    lea    (sp),a1
  8923.     lea    time_text(pc),a0
  8924.     bsr    new_print
  8925.     lea    14(sp),sp
  8926.     moveq    #RETURN_OK,d0
  8927. .B    rts
  8928.  
  8929. settime    movem.l    d1-d4/a0-a4,-(sp)    V2.0
  8930.     move.l    a0,a4        ;a0=parameters
  8931.     move.l    a1,temp1(a5)    ;a1=date/time
  8932. settim    move.l    (a4)+,a0
  8933.     lea    temp2buf(a5),a2
  8934.     moveq    #2,d3
  8935. aa1    move.l    a0,a1
  8936.     bsr    gab
  8937.     move.b    d0,d4
  8938.     beq.s    bb1
  8939.     clr.b    -1(a0)
  8940.     cmp.b    #".",d0        ;day.month.year
  8941.     bne.s    dat2
  8942. bb1    bsr    convert_ASCII_to_num
  8943.     cmp.w    #99,d0    ;rough check
  8944.     bhi    muell
  8945.     move.w    d0,(a2)+
  8946.     tst.l    d1
  8947.     beq    muell
  8948.     tst.b    d4
  8949.     dbeq    d3,aa1
  8950. mull1    tst.w    d3
  8951.     bne    muell
  8952.     lea    temp2buf(a5),a2
  8953.     move.l    temp1(a5),a1
  8954.     moveq    #2,d3
  8955. .B    move.w    (a2)+,(a1)+
  8956.     dbra    d3,.B
  8957.     bra    oktt
  8958. aa2    move.l    a0,a1
  8959.     bsr    gab
  8960.     move.b    d0,d4
  8961.     beq.s    bb2
  8962.     clr.b    -1(a0)
  8963. dat2    cmp.b    #":",d0        ;hour:minute:second
  8964.     bne.s    dat3
  8965. bb2    bsr    convert_ASCII_to_num
  8966.     cmp.w    #99,d0
  8967.     bhi    muell
  8968.     move.w    d0,(a2)+
  8969.     tst.l    d1
  8970.     beq    muell
  8971.     tst.b    d4
  8972.     dbeq    d3,aa2
  8973. mull2    tst.w    d3
  8974.     bne    muell
  8975.     lea    temp2buf(a5),a2
  8976.     move.l    temp1(a5),a1
  8977.     lea    6(a1),a1
  8978.     moveq    #2,d3
  8979. .B    move.w    (a2)+,(a1)+
  8980.     dbra    d3,.B
  8981.     bra    oktt
  8982.     moveq    #2,d3
  8983. aa3    move.l    a0,a1
  8984.     bsr    gab
  8985.     move.b    d0,d4
  8986.     beq.s    bb3
  8987.     clr.b    -1(a0)
  8988. dat3    cmp.b    #"-",d0        ;month-day-year
  8989.     bne    muell
  8990. bb3    bsr    convert_ASCII_to_num
  8991.     cmp.w    #99,d0
  8992.     bhi    muell
  8993.     move.w    d0,(a2)+
  8994.     tst.l    d1
  8995.     beq    muell
  8996.     tst.b    d4
  8997.     dbeq    d3,aa3
  8998. mull3    tst.w    d3
  8999.     bne    muell
  9000.     lea    temp2buf(a5),a2
  9001.     move.l    temp1(a5),a1
  9002.     move.w    (a2)+,2(a1)
  9003.     move.w    (a2)+,(a1)
  9004.     move.w    (a2)+,4(a1)
  9005. oktt    tst.l    (a4)
  9006.     bne    settim
  9007.     lea    chaotab(pc),a0
  9008.     move.l    temp1(a5),a1
  9009.     lea    temp2buf(a5),a3
  9010.     moveq    #5,d0
  9011.     moveq    #0,d1
  9012. .A    move.b    (a0)+,d1
  9013.     move.w    0(a1,d1),d2
  9014.     move.b    d2,(a3)+
  9015.     dbra    d0,.A
  9016.     lea    temp2buf(a5),a3
  9017.     bsr    calcsec
  9018.     movem.l    (sp)+,d1-d4/a0-a4
  9019.     moveq    #RETURN_OK,d0
  9020.     rts    ;result in d5-d7
  9021.  
  9022. muell    lea    muell_tx(pc),a1
  9023.     bsr    pr_stringlf
  9024.     movem.l    (sp)+,d1-d4/a0-a4
  9025.     moveq    #RETURN_ERROR,d0
  9026.     rts
  9027.  
  9028. gab    move.b    (a0)+,d0
  9029.     cmp.b    #$30,d0
  9030.     blo.s    .A
  9031.     cmp.b    #$39,d0
  9032.     bls.s    gab
  9033. .A    cmp.b    #"%",d0    ;handle bin (that's fun !)
  9034.     beq.s    gab
  9035.     rts
  9036.  
  9037. ** GET TIME STORE DAYS,MINUTES,TICKS AT A0
  9038. get_time    move.l    a0,-(sp)
  9039.     move.l    a0,d1
  9040.     jsr    _LVODateStamp(a6)
  9041.     move.l    (sp)+,a0
  9042.     rts
  9043.  
  9044. ** ENTRY A0 pts to 7 words of storage, A1 pts to date stamp
  9045. ** send time to A0 --> 13(A0)
  9046. convert_time
  9047.     movem.l    d0-d3/a0-a2,-(sp)
  9048.     move.l    ds_Tick(a1),d0
  9049.     divu    #50,d0
  9050.     move.w    d0,4+6(a0)        seconds
  9051.     swap    d0
  9052.     asl.w    #1,d0
  9053.     move.w    d0,6+6(a0)        hundredths
  9054.     move.l    ds_Minute(a1),d0
  9055.     divu    #60,d0
  9056.     move.w    d0,0+6(a0)        hours
  9057.     swap    d0    
  9058.     move.w    d0,2+6(a0)        minutes
  9059.     move.l    ds_Days(a1),d0
  9060.     move.w    #365,d1        V2.0:year, day, month
  9061.     move.w    #77,d2
  9062. wdhj    addq.w    #1,d2
  9063.     sub.w    d1,d0
  9064.     bcs.s    mon
  9065.     move.w    d2,d3
  9066.     and.w    #3,d3
  9067.     bne.s    wdhj
  9068.     cmp.w    #100,d2
  9069.     blo.s    ork
  9070.     moveq    #1,d3
  9071.     addq.w    #1,d0
  9072.     sub.w    #100,d2
  9073. ork    subq.w    #1,d0
  9074.     bcc.s    wdhj
  9075.     addq.w    #1,d0
  9076. mon    add.w    d1,d0
  9077.     move.w    d2,4(a0)    year (lots of work)
  9078.     moveq    #0,d2
  9079.     lea    montab(pc),a2
  9080. wdhm    addq.w    #1,d2
  9081.     moveq    #0,d1
  9082.     move.b    (a2)+,d1
  9083.     sub.w    d1,d0
  9084.     bcs.s    tag
  9085.     cmp.w    #2,d2
  9086.     bne.s    wdhm
  9087.     move.w    4(a0),d3
  9088.     beq.s    wdhm
  9089.     and.w    #3,d3
  9090.     bne.s    wdhm
  9091.     subq.w    #1,d0
  9092.     bcc.s    wdhm
  9093.     addq.w    #1,d0
  9094. tag    add.w    d1,d0
  9095.     addq.w    #1,d0
  9096.     move.w    d2,2(a0)    month (i don't like february)
  9097.     move.w    d0,(a0)        day
  9098.     movem.l    (sp)+,d0-d3/a0-a2
  9099.     rts
  9100.  
  9101. montab    dc.b    31,28,31,30,31,30,31,31,30,31,30,31
  9102.  
  9103. *************************
  9104. *    STACK        *
  9105. *************************
  9106. stackz    move.l    CLIptr(a5),a4
  9107.     move.l    cli_DefaultStack(a4),d7
  9108.     lsl.l    #2,d7
  9109.     tst.l    parm2(a5)
  9110.     beq.s    show_stack
  9111.     move.l    parm2(a5),a1
  9112.     bsr    convert_ASCII_to_num
  9113.     beq    bad_number_error
  9114. stk_num_OK
  9115.     move.l    d0,d6
  9116.     cmpi.l    #1600,d6  ;allow 1600 bytes for DOS
  9117.     blt.s    stoosmall
  9118.     move.l    d6,d0
  9119.     moveq    #1,d1   
  9120.     bsr    iwantmem 
  9121.     beq.s    stoobig   
  9122.     move.l    d0,a1   
  9123.     move.l    d6,d0   
  9124.     bsr    givemem  
  9125.     
  9126.     lsr.l    #2,d6
  9127.     move.l    d6,cli_DefaultStack(a4)
  9128.     moveq    #RETURN_OK,d0
  9129.     rts
  9130. stoosmall
  9131.     move.l    #-148,d0
  9132.     bra    pr_galactic
  9133. stoobig
  9134.     bra    resi_no_mem
  9135. show_stack
  9136.     move.l    d7,-(sp)
  9137.     move.l    #-146,d0
  9138.     bsr    GetMessage
  9139.     lea    (sp),a1
  9140.     bsr    new_print
  9141.     move.l    (sp)+,d0
  9142.     moveq    #RETURN_OK,d0
  9143.     rts
  9144.  
  9145. ** CHECK STRING A0 IF ENDING IN :
  9146. ** RETURN EQ IF DOES END IN COLON
  9147. check_for_colon
  9148. .A    tst.b    (a0)+    MAKE SURE ENDS IN :
  9149.     bne.s    .A
  9150.     move.b    -2(a0),d0
  9151.     cmp.b    #':',d0
  9152.     rts
  9153.  
  9154. do_forbid    move.l    4.w,a6
  9155.     jsr    _LVOForbid(a6)
  9156.     move.l    dosbase(a5),a6
  9157.     rts
  9158. do_permit    move.l    4.w,a6
  9159.     jsr    _LVOPermit(a6)
  9160.     move.l    dosbase(a5),a6
  9161.     rts
  9162.     
  9163. *************************
  9164. *    ASSIGN         *
  9165. *************************
  9166. assignz    cmp.w    #36,kickver(a5)
  9167.     blo    assi13
  9168.     tst.l    parm2(a5)
  9169.     beq    assi13
  9170.     move.l    parm3(a5),d2
  9171.     beq    too_less_args
  9172.     move.l    parm2(a5),a2
  9173.     move.l    a2,a0
  9174.     bsr    check_for_colon
  9175.     bne.s    .G
  9176.     clr.b    -2(a0)    no colon-end
  9177. .G    lea    assignuse(pc),a1
  9178.     move.l    parm4(a5),d0
  9179.     bne.s    .B
  9180.     move.l    d2,a0
  9181.     bsr    CheckOpt
  9182.     beq.s    .C
  9183.     move.l    d2,d1        Assign LOCK
  9184.     moveq    #-2,d2
  9185.     jsr    _LVOLock(a6)
  9186.     move.l    d0,d7
  9187.     move.l    d0,d2
  9188.     beq    DOSerr
  9189.     move.l    a2,d1
  9190.     jsr    _LVOAssignLock(a6)
  9191.     tst.l    d0
  9192.     beq    DOSerrUL
  9193.     bra    .A
  9194. .C    move.l    a2,d1        Assign REMOVE
  9195.     moveq    #0,d2
  9196.     jsr    _LVOAssignLock(a6)
  9197.     tst.l    d0
  9198.     beq    DOSerr
  9199.     bra.s    .A
  9200.  
  9201. .B    move.l    d0,a0
  9202.     bsr    CheckOpt
  9203.     bne.s    .H
  9204.     move.l    d2,d1        Assign REMOVE part
  9205.     moveq    #-2,d2
  9206.     jsr    _LVOLock(a6)
  9207.     move.l    d0,d7
  9208.     move.l    d0,d2
  9209.     beq    DOSerr
  9210.     move.l    a2,d1
  9211.     jsr    _LVORemAssignList(a6)
  9212.     tst.l    d0
  9213.     beq    DOSerrUL
  9214.     bra.s    .A
  9215. .H    bsr    CheckOpt
  9216.     bne.s    .D
  9217.     move.l    d2,d1        Assign ADD
  9218.     moveq    #-2,d2
  9219.     jsr    _LVOLock(a6)
  9220.     move.l    d0,d7
  9221.     move.l    d0,d2
  9222.     beq    DOSerr
  9223.     move.l    a2,d1
  9224.     jsr    _LVOAssignAdd(a6)
  9225.     tst.l    d0
  9226.     beq    DOSerrUL
  9227.     bra.s    .A
  9228. .D    bsr    CheckOpt
  9229.     bne.s    .E
  9230.     move.l    a2,d1        Assign PATH
  9231.     jsr    _LVOAssignPath(a6)
  9232.     tst.l    d0
  9233.     beq    DOSerr
  9234.     bra.s    .A
  9235. .E    bsr    CheckOpt
  9236.     bne.s    .F
  9237.     move.l    a2,d1        Assign DEFER
  9238.     jsr    _LVOAssignLate(a6)
  9239.     tst.l    d0
  9240.     beq    DOSerr
  9241.     bra.s    .A
  9242. .F    lea    assignuse(pc),a1
  9243.     bsr    pr_stringlf
  9244. .A    moveq    #RETURN_OK,d0
  9245.     rts
  9246.  
  9247. assi13    bsr    do_forbid        FORBID
  9248.     bsr    get_first_devinfo
  9249.     tst.l    parm2(a5)
  9250.     beq    show_assigns
  9251.     tst.l    parm3(a5)
  9252.     beq    exit_assignf    ONLY TWO PARMS TYPED (NEED 3)
  9253.     move.l    parm2(a5),a0
  9254.     bsr    check_for_colon
  9255.     beq    assi14
  9256.     bsr    do_permit
  9257. no_col    move.l    #210,d0
  9258.     bra    pr_galactic
  9259.     
  9260. assi14    moveq    #dlt_directory,d1    CREATE/MODIFY ASSIGN ******
  9261.     bsr    find_next_assign
  9262.     tst.l    d0
  9263.     bne    no_more_dir_assigns
  9264.     move.l    a0,d5
  9265.     move.l    parm2(a5),a0    A0=assigned name[0]
  9266.     moveq    #0,d2
  9267.     move.b    (a1)+,d2        get char count
  9268. .A    move.b    (a1)+,d0
  9269.     move.b    (a0)+,d1
  9270.     beq.s    assi14
  9271.     subq.l    #1,d2
  9272.     bmi.s    .C
  9273.     bsr    compD1D0nocase
  9274.     beq.s    .A
  9275. .D    bra.s    assi14
  9276.  
  9277. .C    cmp.b    #':',d1    CHANGE EXISTING
  9278.     bne.s    .D
  9279.     bsr    do_permit        PERMIT
  9280.     move.l    d5,a2        GOT A MATCH
  9281.     moveq    #ACCESS_READ,d2
  9282.     move.l    parm3(a5),d1
  9283.     jsr    _LVOLock(a6)
  9284.     tst.l    d0
  9285.     beq    exit_assignp
  9286.     move.l    d0,a3
  9287.     bsr    do_forbid        FORBID
  9288.     move.l    dvi_Lock(a2),d4
  9289.     move.l    a3,dvi_Lock(a2)    new lock
  9290.     add.l    a3,a3
  9291.     add.l    a3,a3
  9292.     move.l    fl_Task(a3),dvi_Task(a2)
  9293.     clr.l    dvi_Handler(a2)
  9294.     clr.l    dvi_StackSize(a2)
  9295.     clr.l    dvi_Priority(a2)
  9296.     clr.l    dvi_Startup(a2)
  9297.     clr.l    dvi_SegList(a2)
  9298.     clr.l    dvi_GlobVec(a2)
  9299.     bsr    do_permit
  9300.     move.l    d4,d1
  9301.     jsr    _LVOUnLock(a6)
  9302.     bra    exit_assignp
  9303.     
  9304. no_more_dir_assigns
  9305.     bsr    do_permit        CREATE NEW ASSIGN
  9306.     moveq    #48,d0
  9307.     move.l    #MEMF_CLEAR+1,d1
  9308.     bsr    iwantmem
  9309.     beq    exit_assignp
  9310.     move.l    d0,a4
  9311.     move.l    #48,(a4)+        save size byte
  9312.     move.l    parm2(a5),a0
  9313.     moveq    #4,d0    4+1 extra bytes for dos(nb: : is ignored)
  9314. .A    addq.l    #1,d0
  9315.     tst.b    (a0)+
  9316.     bne.s    .A
  9317.     move.l    d0,d3    D3=size+5+1    (block size|char_count|chars)
  9318.     moveq    #1,d1
  9319.     bsr    iwantmem
  9320.     beq    rem_dvi
  9321.     move.l    d0,a3
  9322.     move.l    d0,d4        D4=string ptr
  9323.     move.l    d3,(a3)+        save size byte
  9324.     subq.l    #6,d3
  9325.     move.b    d3,(a3)+        save char_count
  9326.     move.l    parm2(a5),a0
  9327.     bra.s    .C
  9328. .B    move.b    d1,(a3)+        copy string to NAME
  9329. .C    move.b    (a0)+,d1
  9330.     cmp.b    #':',d1
  9331.     bne.s    .B
  9332.     clr.b    (a3)        ;NULL-ending V2.0
  9333.     addq.l    #4,d0
  9334.     lsr.l    #2,d0    convert to bstr
  9335.     move.l    d0,dvi_Name(a4)
  9336.     move.l    #dlt_directory,dvi_Type(a4)
  9337.     moveq    #ACCESS_READ,d2
  9338.     move.l    parm3(a5),d1
  9339.     jsr    _LVOLock(a6)
  9340.     tst.l    d0
  9341.     beq    rem_str
  9342.     move.l    d0,dvi_Lock(a4)
  9343.     lsl.l    #2,d0        x 4
  9344.     move.l    d0,a0
  9345.     move.l    fl_Task(a0),dvi_Task(a4)
  9346.     bsr    do_forbid
  9347.     bsr    get_first_devinfo    RETURNS A1 pts info substr, A2 pts 1st devinfo
  9348.     move.l    a2,dvi_Next(a4)
  9349.     move.l    a4,d0
  9350.     lsr.l    #2,d0
  9351.     move.l    d0,di_DevInfo(a1)    Insert new top of chain
  9352.     bsr    do_permit
  9353.     
  9354.     bra.s    exit_assignp
  9355. rem_str    move.l    d4,a1
  9356.     move.l    (a1),d0
  9357.     bsr    givemem
  9358. rem_dvi    lea    -4(a4),a1
  9359.     moveq    #48,d0
  9360.     bsr    givemem
  9361. exit_assignp
  9362.     moveq    #RETURN_OK,d0
  9363.     rts
  9364. exit_assignf
  9365.     bsr    do_permit
  9366.     moveq    #RETURN_OK,d0
  9367.     rts
  9368.     
  9369. * SHOW ASSIGNS    ALREADY IN FORBID STATE
  9370. show_assigns
  9371.     lea    -8(sp),sp
  9372.     move.l    a2,(sp)        0(sp)= BPTR of first devinfo
  9373.     move.l    #5000,d0
  9374.     moveq    #1,d1
  9375.     bsr    iwantmem        allocate big block
  9376.     beq    asg_fail
  9377.     move.l    d0,a4        A4 = string block
  9378.     move.l    d0,a3
  9379.     add.l    #5000,a3    A3 = end of string block
  9380.     move.l    d0,4(sp)        4(sp) = string block
  9381.     lea    volume_tx(pc),a0    PRINT VOLUMES:
  9382.     bsr    copy_name
  9383.     moveq    #dlt_volume,d1
  9384. do_volumes
  9385. .E    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  9386.     tst.l    d0         TO THE BIG STRING
  9387.     bne.s    do_devices1
  9388.     bsr    copy_bstr
  9389.     move.b    #$20,(a4)+    seperate with spaces
  9390.     tst.l    dvi_Task(a0)
  9391.     bne.s    .H
  9392.     lea    unmounted_tx(pc),a0
  9393.     bsr    copy_name
  9394.     bra.s    .A
  9395. .H    move.b    #"[",(a4)+
  9396.     lea    mounted_tx(pc),a0
  9397.     bsr    copy_name
  9398. .A    move.b    #LF,(a4)+
  9399.     bra.s    .E
  9400. do_devices1
  9401.     move.l    (sp),a2        restart at first devinfo
  9402.     lea    device1_tx(pc),a0    PRINT DEVICES:
  9403.     bsr    copy_name
  9404.     lea    device3_tx(pc),a0
  9405.     bsr    copy_name
  9406. .B    moveq    #dlt_device,d1
  9407.     bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  9408.     tst.l    d0         TO THE BIG STRING
  9409.     bne.s    .A
  9410.     tst.l    dvi_Task(a0)
  9411.     bne.s    .B
  9412.     bsr    copy_bstr
  9413.     move.b    #$20,(a4)+    seperate with spaces
  9414.     move.b    #$20,(a4)+
  9415.     bra.s    .B
  9416. .A    move.b    #LF,(a4)+    linefeed at end
  9417. do_devices2
  9418.     move.l    (sp),a2        restart at first devinfo
  9419.     lea    device1_tx(pc),a0    PRINT DEVICES:
  9420.     bsr    copy_name
  9421.     lea    device2_tx(pc),a0
  9422.     bsr    copy_name
  9423. .B    moveq    #dlt_device,d1
  9424.     bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  9425.     tst.l    d0         TO THE BIG STRING
  9426.     bne.s    .A
  9427.     tst.l    dvi_Task(a0)
  9428.     beq.s    .B
  9429.     bsr    copy_bstr
  9430.     move.b    #$20,(a4)+    seperate with spaces
  9431.     move.b    #$20,(a4)+
  9432.     bra.s    .B
  9433. .A    move.b    #LF,(a4)+    linefeed at end
  9434. do_late
  9435.     move.l    (sp),a2
  9436.     lea    assign_tx(pc),a0    PRINT DIRECTORIES
  9437.     bsr    copy_name
  9438.     moveq    #dlt_late,d1
  9439. .B    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  9440.     tst.l    d0         TO THE BIG STRING
  9441.     bne.s    .A
  9442.     bsr    copy_bstr
  9443.     move.b    #":",(a4)+
  9444.     move.b    #9,(a4)+    seperate with tab
  9445.     move.b    #"<",(a4)+
  9446.     move.l    dvi_Handler(a0),a0
  9447.     bsr    copy_name
  9448.     move.b    #">",(a4)+
  9449.     move.b    #LF,(a4)+    linefeed at end
  9450.     bra.s    .B
  9451. .A    move.l    (sp),a2
  9452. do_nonbind
  9453.     moveq    #dlt_nonbind,d1
  9454. .B    bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  9455.     tst.l    d0         TO THE BIG STRING
  9456.     bne.s    .A
  9457.     bsr    copy_bstr
  9458.     move.b    #":",(a4)+
  9459.     move.b    #9,(a4)+    seperate with tab
  9460.     move.b    #"[",(a4)+
  9461.     move.l    dvi_Handler(a0),a0
  9462.     bsr    copy_name
  9463.     move.b    #"]",(a4)+
  9464.     move.b    #LF,(a4)+    linefeed at end
  9465.     bra.s    .B
  9466. .A    move.l    (sp),a2
  9467. do_dirs        ;uses top of big mem block (end in a3)
  9468.     move.w    #-1,-(a3)    push negative
  9469. .G    moveq    #dlt_directory,d1
  9470.     bsr    find_next_assign    COPY ALL DEVICES THAT MATCH TYPE IN D1
  9471.     tst.l    d0         TO THE BIG STRING
  9472.     bne.s    .E
  9473.     clr.l    -(a3)        null-end locks
  9474.     cmp.w    #36,kickver(a5)
  9475.     blo.s    .A        OS1.3-: no assign add
  9476.     move.l    dvi_LockList(a0),d0    search locklist (assign add)
  9477.     beq.s    .A
  9478. .B    move.l    d0,a1
  9479.     move.l    4(a1),-(a3)    push locks
  9480.     move.l    (a1),d0
  9481.     bne.s    .B
  9482. .A    move.l    d2,-(a3)    push main lock
  9483.     clr.b    -(a3)        null-end name
  9484.     move.l    dvi_Name(a0),a1
  9485.     add.l    a1,a1
  9486.     add.l    a1,a1
  9487.     moveq    #0,d0
  9488.     move.b    (a1),d0        name-length
  9489.     btst    #0,d0
  9490.     bne.s    .C
  9491.     clr.b    -(a3)        for word-align
  9492. .C    add.l    d0,a1
  9493.     addq.l    #1,a1        a3=end of name
  9494.     bra.s    .D
  9495. .F    move.b    -(a1),-(a3)
  9496. .D    dbra    d0,.F
  9497.     bra.s    .G
  9498.  
  9499. .E    bsr    do_permit
  9500. get_nxt_lock
  9501.     cmp.b    #$ff,(a3)    check for end
  9502.     beq.s    .A
  9503.     move.l    a3,a0
  9504.     bsr    copy_name    copy assign-name
  9505. .B    tst.b    (a3)+        look for end
  9506.     bne.s    .B
  9507.     move.b    #9,(a4)+    copy tab
  9508.     move.l    a3,d0
  9509.     addq.l    #1,d0
  9510.     and.w    #$fffe,d0    word-align
  9511.     move.l    d0,a3
  9512.     move.l    (a3)+,d1    first lock
  9513.     beq.s    .F
  9514.     bra.s    .G
  9515. .C    move.l    (a3)+,d1
  9516.     beq.s    get_nxt_lock
  9517.     move.b    #9,(a4)+    other locks are assign adds
  9518.     move.b    #"+",(a4)+
  9519.     move.b    #" ",(a4)+
  9520. .G    move.l    d1,a0
  9521.     add.l    a0,a0
  9522.     add.l    a0,a0
  9523.     move.l    fl_Volume(a0),a0
  9524.     add.l    a0,a0
  9525.     add.l    a0,a0
  9526.     tst.l    dvi_Task(a0)    check for mounted
  9527.     bne.s    .E
  9528. .F    lea    unmounted_tx(pc),a0
  9529.     bsr    copy_name
  9530.     move.b    #LF,(a4)+
  9531.     bra.s    .C
  9532. .E    jsr    _LVODupLock(a6)    copy lock(D1) --> (D0)
  9533.     tst.l    d0
  9534.     beq.s    .F        could not dup lock
  9535.     move.l    a4,a0
  9536.     move.l    a3,-(sp)
  9537.     bsr    eval_full_path    write path to big block
  9538.     move.l    (sp)+,a3
  9539.     jsr    _LVOUnLock(a6)
  9540. .D    tst.b    (a4)+        look for end
  9541.     bne.s    .D
  9542.     move.b    #LF,-1(a4)    overwrite null or tab
  9543.     bra.s    .C
  9544. .A    clr.b    (a4)        null-end
  9545.  
  9546.     move.l    a4,d6
  9547.     subq.l    #1,d6
  9548.     move.l    4(sp),a4
  9549.     bsr    rawh_off
  9550.     bsr    pr_screen
  9551.     move.l    4(sp),a1
  9552.     move.l    #5000,d0
  9553.     bsr    givemem
  9554.     bra.s    asg_fail2
  9555. asg_fail    bsr    do_permit
  9556. asg_fail2    lea    8(sp),sp
  9557.     moveq    #RETURN_OK,d0
  9558.     rts
  9559.  
  9560.  
  9561. get_first_devinfo
  9562.     move.l    dl_Root(a6),a1
  9563.     move.l    rn_Info(a1),a1
  9564.     add.l    a1,a1
  9565.     add.l    a1,a1
  9566.     move.l    di_DevInfo(a1),a2    A2=BPTR to first devinfo
  9567.     rts
  9568.  
  9569. copy_name    move.b    (a0)+,(a4)+
  9570.     bne.s    copy_name
  9571.     lea    -1(a4),a4
  9572.     rts
  9573.  
  9574. **COPY BSTR FROM A1 TO A4, DONT NULL END
  9575. copy_bstr    moveq    #0,d0
  9576.     move.b    (a1)+,d0
  9577.     bra.s    .C
  9578. .B    move.b    (a1)+,(a4)+
  9579. .C    dbra    d0,.B
  9580.     rts
  9581.     
  9582. **ENTRY: D1=type ,A2=Bptr of devinfo, EXIT: A2=Bptr to next ,D0=0 if found
  9583. **EXIT: D2=lock, D1=type, A1 pts to string, A0 pts devinfo struct
  9584. find_next_assign
  9585. .A    add.l    a2,a2    FIND NEXT DEVINFO THAT MATCHES THE TYPE (D1)
  9586.     add.l    a2,a2        A2 pts to first devinfo structure
  9587.     move.l    a2,d0        tst.l    (a2)
  9588.     beq.s    .B
  9589.     move.l    a2,a0
  9590.     move.l    dvi_Name(a2),a1
  9591.     move.l    dvi_Lock(a2),d2
  9592.     move.l    dvi_Type(a2),d0
  9593.     move.l    (a2),a2
  9594.     cmp.l    d0,d1
  9595.     bne.s    .A
  9596.     add.l    a1,a1
  9597.     add.l    a1,a1
  9598.     moveq    #0,d0
  9599.     rts
  9600. .B    moveq    #1,d0
  9601.     rts
  9602.  
  9603. *************************
  9604. *    FAILAT         *
  9605. *************************
  9606. failatz    move.l    parm2(a5),d0
  9607.     beq.s    .A
  9608.     move.l    d0,a1
  9609.     bsr    convert_ASCII_to_num
  9610.     beq    bad_number_error
  9611.     move.l    CLIptr(a5),a0
  9612.     move.l    d0,cli_FailLevel(a0)
  9613.     bra.s    .B
  9614. .A    move.l    #-154,d0
  9615.     bsr    GetMessage
  9616.     move.l    CLIptr(a5),a1
  9617.     lea    cli_FailLevel(a1),a1
  9618.     bsr    new_print
  9619. .B    moveq    #RETURN_OK,d0
  9620.     rts
  9621.  
  9622. *************************
  9623. *    IF         *
  9624. *************************
  9625. ifz    move.b    #$ff,if_flag(a5)
  9626.     move.b    #$ff,if_condition(a5)    set FALSE
  9627.     lea    parm2(a5),a4
  9628.     moveq    #0,d4        not state
  9629. .C    move.l    (a4)+,d0
  9630.     beq    if_fail
  9631.     move.l    d0,a0
  9632.     lea    not_tx(pc),a1
  9633.     bsr    compare_strings
  9634.     bne.s    .B
  9635.     not.b    d4        set D4=FF if not
  9636.     bra    .C
  9637. .B    lea    exists(pc),a1
  9638.     bsr    compare_strings
  9639.     bne.s    try_warn    IF NOT AN EXISTS TYPE COMPARE
  9640.     move.l    (a4)+,d1
  9641.     beq    if_fail
  9642.     moveq    #0,d3        d3=0    doesnt exist
  9643.     moveq    #ACCESS_READ,d2
  9644.     jsr    _LVOLock(a6)
  9645.     tst.l    d0
  9646.     beq.s    save_state
  9647.     move.l    d0,d1
  9648.     jsr    _LVOUnLock(a6)
  9649.     not.b    d3        d3=ff    exists
  9650. save_state
  9651.     not.b    d3        d3=0    true
  9652.     eor.b    d4,d3
  9653.     move.b    d3,if_condition(a5)
  9654.     moveq    #RETURN_OK,D0
  9655.     RTS
  9656. try_warn    move.l    last_failcode(a5),d5
  9657.     moveq    #RETURN_WARN,d6
  9658.     lea    warn_tx(pc),a1    CHECK IF 'IF WARN'
  9659.     bsr    compare_strings
  9660.     bne    try_error
  9661. set_error_state
  9662.     moveq    #0,d3
  9663.     cmp.l    d6,d5
  9664.     bne    save_state
  9665.     not.b    d3
  9666.     bra    save_state
  9667. try_error    lea    error_tx(pc),a1
  9668.     bsr    compare_strings
  9669.     bne    try_fail
  9670.     moveq    #RETURN_ERROR,d6
  9671.     bra    set_error_state
  9672. try_fail    lea    fail_tx(pc),a1
  9673.     bsr    compare_strings
  9674.     bne    if_fail
  9675.     moveq    #RETURN_FAIL,d6
  9676.     bra    set_error_state
  9677. if_fail    not.b    if_flag(a5)    clear it
  9678.     bra    too_less_args
  9679.  
  9680. *************************
  9681. *    ASK         *
  9682. *************************
  9683. askz    bsr    echoz        print the parm same as echo does
  9684. rask    bsr    raw_off
  9685.     move.l    stdin(a5),d1
  9686.     beq.s    .A
  9687.     lea    tempbuf(a5),a4    a4:tempbuf
  9688.     clr.b    (a4)
  9689.     move.l    a4,d2
  9690.     moveq    #120,d3
  9691.     jsr    _LVORead(a6)    read input
  9692.     tst.l    d0
  9693.     bmi.s    .A
  9694.     beq.s    .A
  9695.     tst.b    redirect_out(a5)    output redirected ?
  9696.     beq.s    .C
  9697.     move.l    a4,a0
  9698.     add.l    d0,a0
  9699.     subq.l    #1,a0
  9700.     clr.b    (a0)    Null-End
  9701.     move.l    a4,a1
  9702.     bsr    pr_string    repeat input
  9703.     bra    .A
  9704. .C    or.b    #$20,(a4)
  9705.     moveq    #RETURN_FAIL,d0
  9706.     cmp.b    #'f',(a4)    V2.0
  9707.     beq    .B
  9708.     moveq    #RETURN_ERROR,d0
  9709.     cmp.b    #'e',(a4)    V2.0
  9710.     beq    .B
  9711.     moveq    #RETURN_WARN,d0
  9712.     cmp.b    #'j',(a4)    V2.0
  9713.     beq    .B
  9714.     cmp.b    #'y',(a4)
  9715.     beq    .B
  9716. .A    moveq    #RETURN_OK,D0
  9717. .B    rts
  9718.  
  9719. *************************
  9720. *    WAIT         *
  9721. *************************
  9722. waitz    move.l    parm2(a5),d0
  9723.     beq    too_less_args
  9724.     move.l    d0,a1
  9725.     bsr    convert_ASCII_to_num
  9726.     beq    bad_number_error
  9727.     move.l    d0,d4
  9728.     lsl.l    #2,d4        d4*4
  9729.     add.l    d0,d4        d4:=d0*5 (d4*4+d4)
  9730. .C    bsr    check_c
  9731.     bne.s    .E
  9732.     moveq    #LF,d1        1/5 second
  9733.     jsr    _LVODelay(a6)
  9734.     subq.l    #1,d4
  9735.     bne.s    .C
  9736. .E    moveq    #RETURN_OK,D0
  9737.     RTS
  9738.  
  9739. *************************
  9740. *    QUIT         *
  9741. *************************
  9742. * only returns from script files.
  9743. quitz    tst.b    scflag(a5)
  9744.     bne.s    .A
  9745.     moveq    #RETURN_OK,D0
  9746.     RTS
  9747. .A    move.l    parm2(a5),d0
  9748.     beq    .B
  9749.     move.l    d0,a1
  9750.     bsr    convert_ASCII_to_num
  9751.     bne    .B
  9752.     bsr    bad_number_error
  9753. .B    move.l    d0,-(sp)
  9754.     bsr    kill_script    guarantee that script is dead
  9755.     move.l    (sp)+,d0
  9756.     rts
  9757.     
  9758. *************************
  9759. *    HTYPE         *
  9760. *************************
  9761. htypez    tst.b    redirect_in(a5)
  9762.     beq.s    .C
  9763.     bsr    readstdin    read from inhandle
  9764.     bra.s    .D
  9765. .C    move.l    parm2(a5),d0
  9766.     beq    too_less_args
  9767.     move.l    d0,a0
  9768.     bsr    readfile    read from file
  9769. .D    bsr    rawh_off    MAKE SURE YOU CAN PRESS SPACE TO HOLD IT
  9770.     move.l    d0,mem_addr(a5)
  9771.     move.l    d0,mem_offset_addr(a5)
  9772.     move.l    d1,temp1(a5)
  9773.     move.l    d1,d2
  9774.     add.l    d0,d1
  9775.     move.l    d1,d7        end marker
  9776.     move.l    parm3(a5),d0
  9777.     beq.s    .B
  9778.     move.l    d0,a1
  9779.     bsr    convert_ASCII_to_num
  9780.     beq.s    .B
  9781.     cmp.l    d0,d2
  9782.     bls.s    .B
  9783.     add.l    d0,mem_addr(a5)
  9784. .B    bsr    check_c
  9785.     bne    htype_end
  9786.     bsr    show_16_locs
  9787.     cmp.l    mem_addr(a5),d7
  9788.     bhi    .B
  9789. htype_end    move.l    mem_offset_addr(a5),a1
  9790.     move.l    temp1(a5),d0
  9791.     bsr    givemem
  9792.     moveq    #RETURN_OK,D0
  9793.     RTS
  9794.  
  9795. *************************
  9796. *    STRINGS     *
  9797. *************************
  9798. stringsz
  9799.     lea    parm2(a5),a0
  9800.     tst.b    redirect_in(a5)
  9801.     bne.s    .A
  9802.     move.l    (a0),d2
  9803.     beq    too_less_args
  9804.     addq.l    #4,a0
  9805. .A    moveq    #7,d7        7=default number of characters
  9806.     move.l    (a0),d0
  9807.     beq    .C
  9808.     move.l    d0,a1
  9809.     bsr    convert_ASCII_to_num
  9810.     beq    bad_number_error
  9811.     move.l    d0,d7
  9812. .C    tst.b    redirect_in(a5)
  9813.     bne.s    .B
  9814.     move.l    d2,a0
  9815.     bsr    readfile    read from file
  9816.     bra.s    .D
  9817. .B    bsr    readstdin    read from inhandle
  9818. .D    move.l    d0,a4        A4=addr of file
  9819.     move.l    a4,a3
  9820.     move.l    d1,d6        D6=size of file
  9821.     add.l    d0,d1
  9822.     move.l    d1,d4        D4=max addr
  9823.     movem.l    d4-d7/a3-a4,-(sp)
  9824.     bsr    rawh_off
  9825.     movem.l    (sp)+,d4-d7/a3-a4
  9826. str_next    bsr    check_c
  9827.     bne    kill_string_file
  9828.     moveq    #0,d5        D5=current string size
  9829.     move.l    a3,a2
  9830. valid_ch    cmp.l    a3,d4
  9831.     beq    string_fin
  9832.     move.b    (a3)+,d0
  9833.     cmp.b    #' ',d0
  9834.     blo.s    not_valid_char
  9835.     cmp.b    #$7f,d0
  9836.     bhi.s    not_valid_char
  9837.     addq.l    #1,d5
  9838.     bra    valid_ch
  9839. not_valid_char
  9840.     cmp.l    d7,d5
  9841.     blo    str_next
  9842.     bsr    write_my_string
  9843.     bra    str_next
  9844.  
  9845. string_fin
  9846.     cmp.l    d7,d5
  9847.     blo    kill_string_file
  9848.     bsr    write_my_string
  9849. kill_string_file
  9850.     move.l    a4,a1
  9851.     move.l    d6,d0
  9852.     bsr    givemem
  9853.     moveq    #RETURN_OK,D0
  9854.     RTS
  9855.     
  9856. write_my_string
  9857.     move.l    outhandle(a5),d1
  9858.     beq.s    .A
  9859.     move.l    a2,d2
  9860.     move.l    d5,d3
  9861.     jsr    _LVOWrite(a6)
  9862. .A    bra    pr_lf
  9863.  
  9864. *************************
  9865. *    FILENOTE    *
  9866. *************************
  9867. filenotez bsr    fixpam32        V2.0
  9868.     move.l    a0,d1
  9869.     move.l    a1,d2
  9870.     move.l    a1,a2
  9871.     moveq    #78,d0
  9872. .A    tst.b    (a2)+
  9873.     beq.s    fnok
  9874.     dbra    d0,.A
  9875.     moveq    #RETURN_ERROR,d0    ;more than 80 chars
  9876.     rts
  9877. fnok    jsr    _LVOSetComment(a6)
  9878.     addq.l    #1,d0
  9879.     bne    DOSerr
  9880.     rts
  9881.  
  9882. *************************
  9883. *    SEARCH        *    Searches a string in a file
  9884. *************************
  9885. searchz    lea    parm2(a5),a2        V2.0
  9886.     tst.b    redirect_in(a5)
  9887.     beq.s    .G
  9888.     move.l    (a2),d7
  9889.     beq    too_less_args
  9890.     bsr    readstdin    read from inhandle
  9891.     bra.s    .F
  9892. .G    move.l    (a2)+,a0
  9893.     move.l    (a2),d7
  9894.     beq    too_less_args
  9895.     bsr    readfile    read from file
  9896. .F    bsr    rawh_off    MAKE SURE YOU CAN PRESS SPACE TO HOLD IT
  9897.     move.l    d1,d5        d5:size of file
  9898.     move.l    d0,d6
  9899.     add.l    d1,d6
  9900.     move.l    d0,a2
  9901.     move.l    d0,a3        a3:start of file
  9902. .A    move.l    d7,a1        d7:search string
  9903.     move.l    d6,a0        d6:end of file
  9904.     bsr    searchSTR    a2:current searchpos
  9905.     cmp.b    #1,d0
  9906.     beq.s    .B
  9907.     move.l    a0,-(sp)
  9908.     move.l    d7,a0
  9909.     moveq    #-1,d4
  9910. .D    addq.l    #1,d4
  9911.     tst.b    (a0)+        length of searchstr.
  9912.     bne.s    .D
  9913.     move.l    a1,d2
  9914.     move.l    a2,d3
  9915.     sub.l    d2,d3
  9916.     beq.s    .C
  9917.     move.l    outhandle(a5),d1
  9918.     jsr    _LVOWrite(a6)    write part before searchstr.
  9919. .C    lea    farb3(pc),a1
  9920.     bsr    pr_string
  9921.     move.l    a2,d2
  9922.     move.l    d4,d3
  9923.     move.l    outhandle(a5),d1
  9924.     jsr    _LVOWrite(a6)    write searchstr.
  9925.     lea    farb1(pc),a1
  9926.     bsr    pr_string
  9927.     move.l    (sp)+,a0
  9928.     move.l    a2,d2
  9929.     add.l    d4,d2
  9930.     move.l    a0,d3
  9931.     sub.l    d2,d3
  9932.     beq.s    .E
  9933.     move.l    outhandle(a5),d1
  9934.     jsr    _LVOWrite(a6)    write part after searchstr.
  9935. .E    bsr    pr_lf
  9936.     addq.l    #1,a2
  9937.     bsr    check_c
  9938.     beq.s    .A
  9939. .B    move.l    d5,d0
  9940.     move.l    a3,a1
  9941.     bsr    givemem        free file
  9942. endse    moveq    #RETURN_OK,d0
  9943.     rts
  9944.  
  9945. * Searches for a string
  9946. * ENTRY:a1 points to the string to search for (ends in NULL)
  9947. *     a2 points to start position, a0 to end of file, a3 to start
  9948. * EXIT: a2  to found-position, a0 to NULL- or LF-end, a1 to LF-start
  9949. *    d0=1 not found, d0= found NULL-ended, d0=10 found LF-ended
  9950. searchSTR
  9951.     movem.l    d1-d7/a3-a5,-(sp)
  9952.     moveq    #"Z",d5
  9953.     moveq    #"A",d6
  9954.     moveq    #" ",d7
  9955.     move.l    a1,a4
  9956.     moveq    #0,d4
  9957. .B    move.b    (a4)+,d0
  9958.     beq.s    .D
  9959.     addq.l    #1,d4        count chars to search for
  9960.     cmp.b    d5,d0
  9961.     bhi.s    .A
  9962.     cmp.b    d6,d0
  9963.     blo.s    .A
  9964.     add.b    d7,d0
  9965.     move.b    d0,-1(a4)    lowercase them
  9966. .A    bra.s    .B
  9967. .D    move.b    (a1),d0
  9968.     cmp.b    dotchar(a5),d0
  9969.     bne.s    .C
  9970.     move.b    #LF,(a1)    begins with LineFeed
  9971. .C    move.l    a3,a5
  9972.     move.l    a0,d0        calc length of text
  9973.     sub.l    a2,d0
  9974.     sub.l    d4,d0
  9975.     move.l    d0,d4
  9976.     move.l    d4,d3
  9977.     swap    d3
  9978.     moveq    #0,d0
  9979.     moveq    #0,d2
  9980.     move.b    (a1),d2
  9981.     bra.s    seabeg
  9982. seastrt    move.b    (a2)+,d1
  9983.     cmp.b    d5,d1
  9984.     bhi.s    .E
  9985.     cmp.b    d6,d1
  9986.     blo.s    .E
  9987.     add.b    d7,d1
  9988. .E    cmp.b    d2,d1        compare first char
  9989.     bne.s    seabeg
  9990.  
  9991.     lea    1(a1),a3
  9992.     move.l    a2,a4
  9993. .B    move.b    (a3)+,d0
  9994.     beq.s    seafnd
  9995.     move.b    (a4)+,d1
  9996.     cmp.b    d5,d1
  9997.     bhi.s    .F
  9998.     cmp.b    d6,d1
  9999.     blo.s    .F
  10000.     add.b    d7,d1
  10001. .F    cmp.b    d0,d1        compare other chars
  10002.     beq.s    .B
  10003.  
  10004. seabeg    dbra    d4,seastrt
  10005.     dbra    d3,seastrt
  10006.     bra    seaend
  10007.  
  10008. seafnd    subq.l    #1,a2
  10009.     move.l    a2,a1
  10010. .D    cmp.l    a0,a4
  10011.     bhi    seaend
  10012.     move.b    (a4)+,d1    search end
  10013.     beq.s    .G
  10014.     cmp.b    #LF,d1
  10015.     bne.s    .D
  10016.     cmp.b    #LF,(a1)
  10017.     beq.s    .H
  10018. .F    cmp.l    a5,a1
  10019.     bls    .G
  10020.     move.b    -(a1),d0
  10021.     beq.s    .H
  10022.     cmp.b    #LF,d0        search beginning (if LF)
  10023.     bne.s    .F
  10024. .H    addq.l    #1,a1
  10025. .G    move.b    d1,d2
  10026.     lea    -1(a4),a0
  10027.     move.l    d2,d0
  10028.     movem.l    (sp)+,d1-d7/a3-a5
  10029.     rts
  10030. seaend    moveq    #1,d0
  10031.     movem.l    (sp)+,d1-d7/a3-a5
  10032.     rts
  10033.  
  10034. *****************
  10035. *    FAULT    *
  10036. *****************
  10037. faultz    move.l    parm2(a5),d0            V2.0
  10038.     beq    too_less_args
  10039.     move.l    d0,a1
  10040.     bsr    convert_ASCII_to_num
  10041.     beq    bad_number_error
  10042.     bsr    pr_DOSerr
  10043. .A    moveq    #RETURN_OK,d0
  10044.     rts
  10045.  
  10046. *************************
  10047. *    SETCLOCK    *
  10048. *************************
  10049. setclockz lea    $dc0000,a4    ;clockbase    V2.0
  10050.     move.b    1(a4),d4
  10051.     moveq    #75,d1
  10052.     jsr    _LVODelay(a6)
  10053.     cmp.b    1(a4),d4    ;secs changed ?
  10054.     beq.s    noclk
  10055.     lea    clk_tx(pc),a2
  10056.     move.l    parm2(a5),d0
  10057.     beq.s    .A
  10058.     move.l    d0,a0
  10059.     move.l    a2,a1
  10060.     bsr    CheckOpt
  10061.     beq    clkload
  10062.     lea    8(a2),a1
  10063.     bsr    CheckOpt
  10064.     beq.s    clksave
  10065. .A    move.l    a2,a1
  10066.     bsr    pr_stringlf
  10067.     moveq    #RETURN_ERROR,d0
  10068.     rts
  10069. noclk    lea    noclk_tx(pc),a0
  10070.     bsr    PrintError
  10071.     rts
  10072.  
  10073. clksave    lea    date_mark(a5),a2
  10074.     move.l    a2,a0
  10075.     bsr    get_time
  10076.     move.l    a2,a1
  10077.     lea    -14(sp),sp
  10078.     lea    (sp),a0
  10079.     bsr    convert_time
  10080.     move.b    61(a4),d0    ;reset clock
  10081.     or.b    #1,d0        ;(don't use bset or bclr !)
  10082.     move.b    d0,61(a4)
  10083.     move.b    #0,57(a4)
  10084.     move.b    #5,61(a4)
  10085.     move.b    #4,61(a4)
  10086.     move.b    53(a4),d0    ;hold clock
  10087.     or.b    #1,d0
  10088.     move.b    d0,53(a4)
  10089. clks    btst    #1,53(a4)
  10090.     bne.s    clks
  10091.     lea    (sp),a0
  10092.     lea    chaotab(pc),a1
  10093.     moveq    #1,d6
  10094.     moveq    #0,d1
  10095.     moveq    #5,d0
  10096. .A    move.b    (a1)+,d1
  10097.     moveq    #0,d2
  10098.     move.w    0(a0,d1),d2
  10099.     divu    #LF,d2
  10100.     swap    d2
  10101.     move.b    d2,0(a4,d6)
  10102.     swap    d2
  10103.     move.b    d2,4(a4,d6)
  10104.     addq.l    #8,d6
  10105.     dbra    d0,.A
  10106.     move.b    53(a4),d0
  10107.     and.b    #$0e,d0
  10108.     move.b    d0,53(a4)    ;run clock
  10109.     lea    14(sp),sp
  10110.     moveq    #RETURN_OK,d0
  10111.     rts
  10112.  
  10113. chaotab    dc.b    10,8,6,0,2,4
  10114.  
  10115. getclk    move.b    0(a4,d6),d1    ;Read realtimeclock
  10116.     move.b    4(a4,d6),d0    ;(adress in a4,offset in d6)
  10117.     addq.l    #8,d6
  10118.     and.w    #$f,d0
  10119.     and.w    #$f,d1
  10120.     mulu    #LF,d0
  10121.     add.w    d1,d0
  10122.     ext.l    d0    ;result
  10123.     rts
  10124.  
  10125.         ;load current time from realtime-clock
  10126. clkload    move.b    53(a4),d0
  10127.     or.b    #1,d0
  10128.     move.b    d0,53(a4)
  10129. clkw    btst    #1,53(a4)
  10130.     bne.s    clkw
  10131.     lea    -6(sp),sp
  10132.     lea    (sp),a3
  10133.     moveq    #5,d2
  10134.     moveq    #1,d6
  10135. .A    bsr    getclk
  10136.     move.b    d0,(a3)+
  10137.     dbra    d2,.A
  10138.     lea    (sp),a3
  10139.     bsr    calcsec        ;how many secs ?
  10140.     move.b    53(a4),d0
  10141.     and.b    #$0e,d0
  10142.     move.b    d0,53(a4)
  10143.     lea    6(sp),sp
  10144.     bsr    tset        ;give it to system
  10145.     moveq    #RETURN_OK,d0
  10146.     rts
  10147.  
  10148. calcsec    moveq    #0,d7        ;a3->points to 6 bytes of date/time
  10149.     moveq    #1,d6                    V2.0
  10150.     move.b    (a3)+,d7    ;sec (collect secs in d7)
  10151.     moveq    #0,d0
  10152.     move.b    (a3)+,d0    ;min
  10153.     mulu    #smin,d0
  10154.     add.l    d0,d7
  10155.     moveq    #0,d0
  10156.     move.b    (a3)+,d0    ;std
  10157.     mulu    #sst,d0
  10158.     add.l    d0,d7
  10159.     moveq    #0,d0
  10160.     move.b    (a3)+,d0    ;tag
  10161.     subq.l    #1,d0
  10162.     move.l    d0,d5        ;collect days in d5
  10163.     moveq    #0,d2
  10164.     move.b    (a3)+,d2    ;monat
  10165.     lea    montab(pc),a0
  10166.     moveq    #0,d3
  10167.     move.b    (a3)+,d3    ;jahr
  10168.     move.l    d3,d0
  10169.     and.w    #3,d0
  10170.     bne.s    nosj
  10171.     move.b    #29,1(a0)    ;change montab
  10172. nosj    subq.l    #2,d2
  10173.     bmi.s    jan
  10174. madd    moveq    #0,d0
  10175.     move.b    0(a0,d2),d0
  10176.     add.w    d0,d5
  10177.     dbra    d2,madd
  10178. jan    cmp.b    #78,d3
  10179.     beq.s    tset
  10180.     subq.l    #1,d3
  10181.     moveq    #0,d1
  10182. jadd    add.w    #tjahr,d5
  10183.     move.l    d3,d0
  10184.     and.w    #3,d0
  10185.     bne.s    nosj2
  10186.     addq.l    #1,d5
  10187. nosj2    cmp.b    #78,d3
  10188.     dbeq    d3,jadd
  10189.     move.b    #28,1(a0)
  10190.     move.l    #stag,d1
  10191.     move.l    d5,d0
  10192.     bsr    mult_32x32
  10193.     move.l    d7,d6        ;d6=secs, d5=days
  10194.     add.l    d0,d7        ;d7=all seconds since 1.1.78
  10195.     rts
  10196.  
  10197. clrio    lea    io_Message(a5),a1    ;initialisiert IO-Request  V2.0
  10198.     move.l    a1,a0
  10199.     moveq    #$2f,d0
  10200. clst3    clr.b    (a0)+
  10201.     dbra    d0,clst3
  10202.     move.b    #5,io_Message+8(a5)
  10203.     move.l    thistask(a5),a0
  10204.     lea    pr_MsgPort(a0),a0
  10205.     move.l    a0,io_Message+14(a5)
  10206.     move.w    #$30,io_Message+18(a5)
  10207.     rts        ;a1:IO-Request a0:Msg-Port
  10208.  
  10209. tset    move.l    4.w,a6        ;set time with timer-device (secs in d7)
  10210.     bsr    clrio                V2.0
  10211.     move.w    #40,io_Message+18(a5)
  10212.     lea    timdev(pc),a0
  10213.     moveq    #1,d0
  10214.     moveq    #0,d1
  10215.     jsr    _LVOOpenDev(a6)
  10216.     tst.l    d0
  10217.     bne    tmfehl
  10218.     lea    io_Message(a5),a1
  10219.     move.w    #11,io_Command(a5)
  10220.     clr.w    io_Flags(a5)
  10221.     move.l    d7,tv_secs(a5)
  10222.     clr.l    tv_micro(a5)
  10223.     jsr    _LVODoIO(a6)
  10224.     tst.l    d0
  10225. ;    bne.s    tmfehl    ;better leave out
  10226.     lea    io_Message(a5),a1
  10227.     clr.l    io_Command(a5)
  10228.     jsr    _LVOCloseDev(a6)
  10229. tmfehl    move.l    dosbase(a5),a6
  10230.     rts
  10231.  
  10232. smin    equ    60
  10233. sst    equ    60*smin
  10234. stag    equ    24*sst
  10235. tjahr    equ    365
  10236.  
  10237.  
  10238. *************************
  10239. *    SHOW        *
  10240. *************************
  10241. soffs    dc.w    378,336,350,364,322,392,532
  10242.  
  10243. showz    bsr    rawh_off            V2.0
  10244.     move.l    parm2(a5),d0
  10245.     beq    sdft
  10246.     move.l    d0,a0
  10247.     move.b    (a0),d1
  10248.     bset    #5,d1
  10249.     cmp.b    #"t",d1
  10250.     beq    shtask
  10251.     cmp.b    #"v",d1
  10252.     beq    shvec
  10253.     lea    styp(pc),a0
  10254.     moveq    #6,d0    ;7 Lists
  10255. .D    cmp.b    0(a0,d0.w),d1
  10256.     dbeq    d0,.D
  10257.     move.w    d0,d7
  10258.     bmi    sdft
  10259.     lea    show_tx(pc),a1
  10260.     cmp.w    #2,d7
  10261.     bhi.s    .C
  10262.     lea    show2_tx(pc),a1
  10263. .C    bsr    pr_stringlf
  10264.     bsr    do_forbid
  10265.     add.w    d0,d0
  10266.     lea    soffs(pc),a0
  10267.     move.w    0(a0,d0.w),d0
  10268.     move.l    4.w,a4
  10269.     move.l    0(a4,d0.w),a1
  10270. ;    move.l    8(a4,d0.w),a2
  10271.     lea    tempbuf(a5),a3
  10272. .A    tst.l    (a1)
  10273.     beq.s    .B
  10274.     move.l    a1,(a3)+
  10275.     move.l    (a1),a1
  10276.     bra.s    .A
  10277. .B    clr.l    (a3)
  10278.     bsr    do_permit
  10279.     lea    tempbuf(a5),a3
  10280. da    tst.l    (a3)
  10281.     beq    sdf
  10282.     move.l    (a3)+,a2
  10283.     move.l    10(a2),-(sp)
  10284.     lea    shform(pc),a0
  10285.     cmp.w    #2,d7
  10286.     bhi.s    .E
  10287.     lea    shform2(pc),a0
  10288.     move.w    22(a2),-(sp)
  10289.     move.w    20(a2),-(sp)
  10290. .E    move.b    9(a2),d0
  10291.     ext.w    d0
  10292.     move.w    d0,-(sp)
  10293.     move.l    a2,-(sp)
  10294.     lea    (sp),a1
  10295.     bsr    new_print
  10296.     lea    10(sp),sp
  10297.     cmp.w    #2,d7
  10298.     bhi.s    da
  10299.     addq.l    #4,sp
  10300.     bra.s    da
  10301. sdft    lea    shuse_tx(pc),a1
  10302.     bsr    pr_stringlf
  10303.     moveq    #RETURN_BAD,d0
  10304.     rts
  10305. sdf    moveq    #RETURN_OK,d0
  10306.     rts
  10307.  
  10308. shtask    lea    tempbuf(a5),a3    enough for 96 tasks
  10309.     move.l    4.w,a6
  10310.     jsr    _LVOForbid(a6)
  10311.     lea    420(a6),a0
  10312.     move.l    (a0),a1
  10313. .A    tst.l    (a1)
  10314.     beq.s    .B
  10315.     move.l    a1,(a3)+
  10316.     move.l    (a1),a1
  10317.     bra.s    .A
  10318. .B    lea    406(a6),a0
  10319.     move.l    (a0),a1
  10320. .C    tst.l    (a1)
  10321.     beq.s    .D
  10322.     move.l    a1,(a3)+
  10323.     move.l    (a1),a1
  10324.     bra.s    .C
  10325. .D    move.l    276(a6),(a3)+
  10326.     clr.l    (a3)
  10327.     jsr    _LVOPermit(a6)
  10328.     move.l    dosbase(a5),a6
  10329.     lea    shta_tx(pc),a1
  10330.     bsr    pr_stringlf
  10331.     lea    tempbuf(a5),a3
  10332. prsht    move.l    (a3)+,a2
  10333.     move.l    10(a2),-(sp)
  10334.     move.l    #$00540061,d0    Task
  10335.     cmp.b    #13,LN_TYPE(a2)
  10336.     bne.s    .C
  10337.     move.l    #$00500072,d0    Process
  10338.     cmp.w    #36,kickver(a5)
  10339.     blo.s    .C
  10340.     tst.l    pr_ExitCode(a2)
  10341.     beq.s    .C
  10342.     move.l    #$00500021,d0    Process with exit code
  10343. .C    move.l    d0,-(sp)
  10344.     move.l    tc_SigWait(a2),-(sp)
  10345.     moveq    #0,d0
  10346.     move.b    tc_State(a2),d0
  10347.     lea    ttyp(pc),a0
  10348.     bra.s    .A
  10349. .B    tst.b    (a0)+
  10350.     bne.s    .B
  10351. .A    dbra    d0,.B
  10352.     move.l    a0,-(sp)
  10353.     move.b    LN_PRI(a2),d0
  10354.     ext.w    d0
  10355.     move.w    d0,-(sp)
  10356.     move.l    a2,-(sp)
  10357.     lea    (sp),a1
  10358.     lea    shtaform(pc),a0
  10359.     bsr    new_print        Print it
  10360.     lea    22(sp),sp
  10361.  
  10362.     cmp.b    #13,LN_TYPE(a2)
  10363.     bne.s    snocli
  10364.     move.l    pr_CLI(a2),d1
  10365.     beq.s    snocli
  10366.     lsl.l    #2,d1    ;cli-process
  10367.     move.l    d1,a4
  10368.     lea    null(pc),a1
  10369.     move.l    a1,-(sp)
  10370.     move.l    pr_COS(a2),d1
  10371.     cmp.l    cli_StandardOutput(a4),d1
  10372.     beq.s    .J
  10373.     lea    bigger(pc),a0
  10374.     move.l    a0,(sp)
  10375. .J    move.l    a1,-(sp)
  10376.     move.l    pr_CIS(a2),d1
  10377.     cmp.l    cli_StandardInput(a4),d1
  10378.     beq.s    .G
  10379.     lea    smaller(pc),a0
  10380.     move.l    a0,(sp)
  10381. .G    move.l    a1,-(sp)
  10382.     move.l    cli_CommandName(a4),d1
  10383.     beq.s    .H
  10384.     lsl.l    #2,d1
  10385.     move.l    d1,a0
  10386.     lea    temp2buf(a5),a1        BSTR !
  10387.     move.l    a1,(sp)
  10388.     moveq    #0,d1
  10389.     move.b    (a0)+,d1
  10390.     bra.s    .E
  10391. .F    move.b    (a0)+,(a1)+
  10392. .E    dbra    d1,.F
  10393.     clr.b    (a1)
  10394. .H    move.l    pr_TaskNum(a2),-(sp)
  10395.     lea    null(pc),a1
  10396.     move.l    a1,-(sp)
  10397.     tst.l    cli_Background(a4)    background ?
  10398.     beq.s    .I
  10399.     lea    backcli(pc),a1
  10400.     move.l    a1,(sp)
  10401. .I    lea    proform(pc),a0
  10402.     lea    (sp),a1
  10403.     bsr    new_print        Print CLI-Add
  10404.     lea    20(sp),sp
  10405. snocli    bsr    pr_lf
  10406.     tst.l    (a3)
  10407.     bne    prsht    ;at least one task
  10408. shtok    moveq    #RETURN_OK,D0
  10409.     rts
  10410.  
  10411. shvec    move.l    4.w,a0
  10412.     move.l    eb_KickCheckSum(a0),-(sp)
  10413.     move.l    eb_ColdCapture(a0),-(sp)
  10414.     move.l    eb_KickTagPtr(a0),-(sp)
  10415.     move.l    eb_CoolCapture(a0),-(sp)
  10416.     move.l    eb_KickMemPtr(a0),-(sp)
  10417.     move.l    eb_WarmCapture(a0),-(sp)
  10418.     lea    (sp),a1
  10419.     lea    vec_line(pc),a0
  10420.     bsr    new_print
  10421.     moveq    #RETURN_ERROR,d0
  10422.     moveq    #5,d1
  10423.     move.l    sp,a0
  10424. .A    tst.l    (a0)+
  10425.     bne.s    .B
  10426.     dbra    d1,.A
  10427.     moveq    #RETURN_OK,d0
  10428. .B    lea    6*4(sp),sp    get rid of trash
  10429.     rts
  10430.  
  10431.  
  10432. *************************
  10433. *    MemClock    *    V2.0
  10434. *************************
  10435.  
  10436. ckstackSIZE    equ    2000
  10437. cktask    equ    0        ;Task-Struct
  10438. ckport    equ    cktask+92    ;MsgPort
  10439. ckstack    equ    ckport+34    ;Stack
  10440. ckustack equ    ckstack+ckstackSIZE
  10441. ckdos    equ    ckustack    ;DOSBase
  10442. ckint    equ    ckdos+4        ;Intuitionbase
  10443. ckitxt    equ    ckint+4        ;IntuiTextStruct
  10444. ckdate    equ    ckitxt+20    ;DateStamp
  10445. ckrawdo    equ    ckdate+12    ;DataStream
  10446. ckcook    equ    ckrawdo+6+8    ;Formatted String
  10447. ckrast    equ    ckcook+40    ;Rastports of all Windows
  10448. cknum    equ    ckrast+20*4    ;Number of Windows
  10449. ckalarm    equ    cknum+4        ;Alarm-Time
  10450. ckpad    equ    ckalarm+8
  10451. cksize    equ    ckpad+2
  10452.  
  10453. mlnode    equ    0        ;Memory-List
  10454. mlnum    equ    mlnode+14
  10455. mladdr    equ    mlnum+2
  10456. mllen    equ    mladdr+4
  10457. mlsize    equ    mllen+4
  10458.  
  10459. memclkz    move.l    parm2(a5),d0
  10460.     beq    too_less_args
  10461.     move.l    d0,a0
  10462.     move.b    (a0),d0
  10463.     bset    #5,d0
  10464.     cmp.b    #"a",d0    ;alarm
  10465.     beq    clkalm
  10466.     bsr    CheckOnOff
  10467.     beq    clkoff
  10468.  
  10469. clkon    move.b    #1,memclk_flag(a5)    switch it on
  10470.     move.l    4.w,a6
  10471.     lea    clktask(pc),a1
  10472.     jsr    _LVOFindTask(a6)
  10473.     move.l    d0,a4
  10474.     tst.l    d0
  10475.     beq.s    .A    ;not already running
  10476.     bsr    winclk
  10477. .B    moveq    #RETURN_OK,d0
  10478.     rts
  10479. .A    move.l    #cksize,d0
  10480.     move.l    #1+1<<16,d1
  10481.     jsr    _LVOAllocMem(a6)
  10482.     tst.l    d0
  10483.     beq.s    .B
  10484.     move.l    d0,a4
  10485.     move.w    #$0104,cktask+8(a4)    ;type/pri
  10486.     lea    clktask(pc),a0
  10487.     move.l    a0,cktask+10(a4)    ;name
  10488.     lea    ckstack(a4),a0
  10489.     lea    ckustack(a4),a1
  10490.     move.l    a1,cktask+54(a4)    ;SPreg
  10491.     move.l    a0,cktask+58(a4)    ;lowerstack
  10492.     move.l    a1,cktask+62(a4)    ;upperstack
  10493.     move.l    a4,ckport+16(a4)    ;sigtask
  10494.     lea    ckport+20+4(a4),a0
  10495.     move.l    a0,ckport+20(a4)
  10496.     lea    ckport+20(a4),a0
  10497.     move.l    a0,ckport+20+8(a4)
  10498.     move.l    #mlsize,d0
  10499.     move.l    #1+1<<16,d1
  10500.     jsr    _LVOAllocMem(a6)
  10501.     tst.l    d0
  10502.     beq.s    .B
  10503.     move.l    d0,a2
  10504.     moveq    #1,d0
  10505.     move.w    d0,mlnum(a2)
  10506.     move.l    a4,mladdr(a2)
  10507.     move.l    #cksize,mllen(a2)
  10508.     lea    mlnode(a2),a0
  10509.     lea    cktask+78(a4),a1
  10510.     move.l    a0,-4(a1)
  10511.     move.l    a0,4(a1)
  10512.     move.l    a1,(a0)
  10513.     move.l    a1,4(a0)
  10514.     move.l    dosbase(a5),ckdos(a4)
  10515.     move.l    intuibase(a5),ckint(a4)
  10516.     bsr    winclk
  10517.     move.l    4.w,a6
  10518.     move.l    a4,a1
  10519.     lea    clkstart(pc),a2
  10520.     moveq    #0,d0
  10521.     move.l    d0,a3
  10522.     jsr    _LVOAddTask(a6)
  10523.     move.l    dosbase(a5),a6
  10524.     moveq    #RETURN_OK,d0
  10525.     rts
  10526.  
  10527. winclk    bsr    findrast    ;check if rastport already exists,
  10528.     tst.w    d1        ;else move rastport in table
  10529.     bpl.s    .C
  10530.     moveq    #19,d1
  10531. .B    tst.l    (a1)+
  10532.     dbeq    d1,.B
  10533.     bne.s    .C
  10534.     move.l    d0,-4(a1)
  10535. .C    rts
  10536.  
  10537. findrast
  10538.     move.l    dosbase(a5),a6
  10539.     bsr    GetWindowPtr    window-ptr to d0
  10540.     beq.s    .B
  10541.     move.l    d0,a0
  10542.     move.l    $32(a0),d0    rastport
  10543.     lea    ckrast(a4),a0
  10544.     move.l    a0,a1
  10545.     moveq    #19,d1
  10546. .A    cmp.l    (a0)+,d0
  10547.     dbeq    d1,.A
  10548. .B    rts
  10549.  
  10550. clkoff    clr.b    memclk_flag(a5)    switch it off
  10551. clkof2    move.l    a4,-(sp)
  10552.     move.l    4.w,a6
  10553.     lea    clktask(pc),a1
  10554.     jsr    _LVOFindTask(a6)
  10555.     move.l    d0,a4
  10556.     tst.l    d0
  10557.     beq.s    .A
  10558.     bsr    findrast
  10559.     tst.w    d1
  10560.     bmi.s    .A
  10561.     moveq    #0,d0
  10562.     move.l    d0,-4(a0)
  10563. .A    move.l    (sp)+,a4
  10564.     move.l    dosbase(a5),a6
  10565.     moveq    #RETURN_OK,d0
  10566.     rts    
  10567.  
  10568. clkalm    move.l    4.w,a6        ;set alarm-time
  10569.     lea    clktask(pc),a1
  10570.     jsr    _LVOFindTask(a6)
  10571.     move.l    dosbase(a5),a6
  10572.     move.l    d0,a4
  10573.     tst.l    d0
  10574.     beq.s    .A
  10575.     tst.l    parm3(a5)
  10576.     bne.s    .B
  10577.     lea    ckalarm(a4),a1
  10578.     bsr    pr_stringlf    show alarm
  10579.     bra.s    .A
  10580. .B    move.l    parm3(a5),a0
  10581.     lea    ckalarm(a4),a1
  10582.     moveq    #7,d0
  10583. .C    move.b    (a0)+,(a1)+    set alarm
  10584.     dbra    d0,.C
  10585. .A    moveq    #RETURN_OK,d0
  10586.     rts    
  10587.  
  10588. clkstart sub.l    a1,a1    ;Here starts the MemClockTaskCode !
  10589.     move.l    4.w,a6
  10590.     jsr    _LVOFindTask(a6)
  10591.     move.l    d0,a5
  10592.     move.l    #$00010100,ckitxt(a5)
  10593. .A    move.l    d5,cknum(a5)    ;teststuff
  10594.     lea    ckdate(a5),a0
  10595.     move.l    a0,d1
  10596.     move.l    ckdos(a5),a6
  10597.     jsr    _LVODateStamp(a6)
  10598.     move.l    ckdate+4(a5),d0        ;mins
  10599.     divu    #60,d0
  10600.     move.w    d0,ckrawdo+8(a5)
  10601.     swap    d0
  10602.     move.w    d0,ckrawdo+10(a5)
  10603.     move.l    ckdate+8(a5),d0        ;secs
  10604.     divu    #50,d0
  10605.     move.w    d0,ckrawdo+12(a5)
  10606.     moveq    #2,d1
  10607.     move.l    4.w,a6
  10608.     jsr    _LVOAvailMem(a6)    ;memory
  10609.     move.l    d0,ckrawdo+4(a5)
  10610.     moveq    #1,d1
  10611.     jsr    _LVOAvailMem(a6)
  10612.     move.l    d0,ckrawdo+0(a5)
  10613.     lea    clkform(pc),a0
  10614.     lea    ckrawdo(a5),a1
  10615.     lea    KPutChar(pc),a2
  10616.     lea    ckcook(a5),a3
  10617.     jsr    _LVORawDoFmt(a6)    ;rawdofmt
  10618.     lea    ckcook+26(a5),a0
  10619.     lea    ckalarm(a5),a1
  10620.     moveq    #7,d0
  10621. .D    move.b    (a0)+,d1
  10622.     cmp.b    (a1)+,d1
  10623.     bne.s    .E
  10624.     dbra    d0,.D
  10625.     move.l    ckint(a5),a6
  10626.     suba.l    a0,a0
  10627.     jsr    _LVODisplayBeep(a6)
  10628. .E    lea    ckcook(a5),a0
  10629.     move.l    a0,ckitxt+12(a5)
  10630.     lea    ckrast(a5),a2
  10631.     moveq    #0,d5
  10632.     moveq    #19,d4
  10633. .B    move.l    (a2)+,a0        ;check all 20 Rastports
  10634.     move.l    a0,d0
  10635.     beq.s    .C
  10636.     addq.l    #1,d5
  10637.     lea    ckitxt(a5),a1
  10638.     moveq    #0,d0
  10639.     moveq    #1,d1
  10640.     move.l    ckint(a5),a6
  10641.     jsr    _LVOPrintIText(a6)
  10642. .C    dbra    d4,.B
  10643.     moveq    #LF,d1
  10644.     move.l    ckdos(a5),a6
  10645.     jsr    _LVODelay(a6)        ;wait 1/5 sec
  10646.     tst.l    d5
  10647.     bne    .A
  10648.     move.l    4.w,a6
  10649.     rts
  10650.  
  10651.  
  10652. *************************
  10653. *    CONFIG        *    V2.0
  10654. *************************    set or show configuration
  10655. configz    move.l    parm2(a5),d0
  10656.     beq    ctrlerr
  10657.     move.l    d0,a0
  10658.     lea    configuse(pc),a1
  10659. ctrlkey    bsr    CheckOpt    keys pressed with CTRL
  10660.     bne.s    ctrlmor
  10661.     move.l    parm3(a5),d0
  10662.     beq.s    .A
  10663.     move.l    d0,a0
  10664.     lea    ctrl_codes(a5),a1
  10665.     moveq    #ctrl_inite-ctrl_init-2,d1
  10666. .B    move.b    (a0)+,d0
  10667.     beq.s    .D
  10668.     and.b    #$3f,d0        set ctrl codes
  10669.     move.b    d0,(a1)+
  10670.     dbra    d1,.B
  10671.     bra.s    .D
  10672. .A    lea    ctrl_codes(a5),a0    show ctrl codes
  10673.     lea    tempbuf(a5),a1
  10674.     move.l    a1,a2
  10675.     moveq    #ctrl_inite-ctrl_init-2,d1
  10676. .C    move.b    (a0)+,d0
  10677.     add.b    #$40,d0
  10678.     move.b    d0,(a2)+
  10679.     dbra    d1,.C
  10680.     clr.b    (a2)
  10681.     bsr    pr_stringlf
  10682. .D    bra.s    ctrl2
  10683.  
  10684. ctrlmor    bsr    CheckOpt    keys pressed in MORE
  10685.     bne.s    ctrldot
  10686.     move.l    parm3(a5),d0
  10687.     beq.s    .A
  10688.     bsr    parse_echo
  10689.     move.l    parm3(a5),a0
  10690.     lea    morekeys(a5),a1
  10691.     moveq    #more_inite-more_init-1,d1
  10692. .B    move.b    (a0)+,d0
  10693.     beq.s    .D
  10694.     move.b    d0,(a1)+    set MORE keys
  10695.     dbra    d1,.B
  10696.     bra.s    .D
  10697. .A    lea    morekeys(a5),a1    show more keys
  10698.     bsr    pr_stringlf
  10699. .D    bra.s    ctrl2
  10700.  
  10701. ctrldot    bsr    CheckOpt    dot (.) character
  10702.     bne.s    ctrlign
  10703.     move.l    parm3(a5),d0
  10704.     beq    too_less_args
  10705.     move.l    d0,a0
  10706.     move.b    (a0),dotchar(a5)
  10707. ctrl2    bra.s    ctrl3
  10708.  
  10709. ctrlign    bsr    CheckOpt    ignore-string for DIR and FNC
  10710.     bne.s    ctrlcol
  10711.     tst.l    parm3(a5)    set or show exeptions of
  10712.     beq.s    .A        filenamecompletition or dir
  10713.     bsr    FreeFNC
  10714.     move.l    parm3(a5),a0
  10715.     bsr    handle_wild_dirs
  10716.     lea    wild_string(a5),a0
  10717.     lea    FNCignore(a5),a1
  10718.     moveq    #30-2,d0
  10719. .B    move.b    (a0)+,(a1)+
  10720.     beq    .D
  10721.     dbra    d0,.B
  10722.     bra.s    .D
  10723. .A    lea    FNCignore(a5),a1
  10724.     bsr    pr_stringlf
  10725. .D    bra.s    ctrl3
  10726.  
  10727. ctrlcol    bsr    CheckOpt    redefine colors
  10728.     bne.s    ctrlcpy
  10729.     move.l    parm3(a5),d0
  10730.     beq    too_less_args
  10731.     move.l    d0,a3
  10732.     lea    start(pc),a0
  10733.     lea    recol1(pc),a1
  10734.     lea    recol2(pc),a2
  10735.     moveq    #0,d1
  10736.     moveq    #0,d2
  10737.     moveq    #(recol2-recol1)/2-1,d0
  10738. .A    move.w    (a1)+,d1
  10739.     move.b    (a2)+,d2
  10740.     move.b    0(a3,d2.l),d3
  10741.     move.b    d3,0(a0,d1.l)
  10742.     dbra    d0,.A
  10743. ctrl3    bra.s    ctrlend
  10744.  
  10745. ctrlcpy    bsr    CheckOpt    buffer for copy/move/join/split
  10746.     bne.s    ctrlfnc
  10747.     move.l    parm3(a5),d0
  10748.     beq.s    .A
  10749.     move.l    d0,a1
  10750.     bsr    convert_ASCII_to_num
  10751.     beq    bad_number_error
  10752.     move.l    d0,copysize(a5)
  10753.     bra.s    ctrlend
  10754. .A    lea    copysize(a5),a1
  10755.     bra.s    ShowBuffer
  10756.  
  10757. ctrlfnc    bsr    CheckOpt    buffer for filenamecompletion
  10758.     bne.s    ctrlerr
  10759.     tst.l    parm3(a5)
  10760.     beq.s    .A
  10761.     bsr    FreeFNC
  10762.     move.l    parm3(a5),a1
  10763.     bsr    convert_ASCII_to_num
  10764.     beq    bad_number_error
  10765.     move.l    d0,FNCsize(a5)
  10766.     bra.s    ctrlend
  10767. .A    lea    FNCsize(a5),a1
  10768.     bra.s    ShowBuffer
  10769.  
  10770. ctrlerr    lea    configuse(pc),a1
  10771.     bsr    pr_stringlf
  10772. ctrlend    moveq    #RETURN_OK,d0
  10773.     rts
  10774.  
  10775. ShowBuffer    ;shows bytesize in (A1)
  10776.     lea    bytes_tx(pc),a0
  10777.     bsr    new_print
  10778.     bra.s    ctrlend
  10779.  
  10780. *************************
  10781. *    Locate        *    V2.0
  10782. ************************* Show the Path and Filename of a Lock-Struct
  10783. locatez            ;or lock object or delete lock
  10784.     bsr    rawh_off
  10785.     lea    parm2(a5),a3
  10786.     move.l    (a3),d0
  10787.     beq    ShowLocks
  10788.     move.l    d0,a0
  10789.     moveq    #0,d7
  10790.     bsr    return_dash_option
  10791.     cmp.b    #"C",d0
  10792.     bne.s    .F
  10793.     moveq    #-1,d7        delete lock after showing
  10794.     addq.l    #4,a3
  10795.     tst.l    (a3)
  10796.     beq.s    SyntaxError
  10797. .F    move.l    (a3),a1
  10798.     bsr    convert_ASCII_to_num
  10799.     bne.s    ShowLock
  10800.  
  10801.     move.l    4(a3),d0    access mode
  10802.     beq.s    SyntaxError
  10803.     move.l    d0,a0
  10804.     moveq    #ACCESS_READ,d2
  10805.     lea    lockread(pc),a1
  10806.     bsr    CheckOpt
  10807.     beq.s    .E
  10808.     moveq    #ACCESS_WRITE,d2
  10809.     lea    lockwrite(pc),a1
  10810.     bsr    CheckOpt
  10811.     bne.s    SyntaxError
  10812. .E    move.l    (a3),d1        name to lock
  10813.     jsr    _LVOLock(a6)    get new lock
  10814.     tst.l    d0
  10815.     bne.s    ShowLock
  10816. SyntaxError
  10817.     moveq    #-119,d0
  10818.     bra    pr_galactic
  10819.  
  10820. ShowLock
  10821.     lea    -12(sp),sp    write out name of lock
  10822.     move.l    d0,(sp)        d7<>0 : delete lock
  10823.     move.l    d0,d6
  10824.     lsl.l    #2,d0
  10825.     move.l    d0,a0
  10826.     lea    lockwrite(pc),a1
  10827.     moveq    #ACCESS_WRITE,d1
  10828.     cmp.l    fl_Access(a0),d1    what kind of lock
  10829.     beq.s    .C
  10830.     lea    lockread(pc),a1
  10831.     subq.l    #1,d1
  10832.     cmp.l    fl_Access(a0),d1
  10833.     bne.s    .A
  10834. .C    move.l    a1,4(sp)
  10835.     move.l    d6,d1
  10836.     jsr    _LVODupLock(a6)
  10837.     lea    tempbuf(a5),a0
  10838.     move.l    a0,8(sp)
  10839.     bsr    eval_full_path    evaluate the full name
  10840.     jsr    _LVOUnLock(a6)
  10841.     move.l    sp,a1
  10842.     lea    locktext(pc),a0
  10843.     bsr    new_print
  10844. .A    lea    12(sp),sp
  10845.     tst.l    d7
  10846.     beq.s    .G
  10847.     move.l    d6,d1
  10848.     jsr    _LVOUnLock(a6)
  10849.     lea    deleteOK(pc),a1
  10850.     bsr    pr_string
  10851. .G    bra.s    LockOK
  10852.  
  10853. ShowLocks
  10854.     moveq    #0,d3
  10855.     bsr    get_first_devinfo
  10856. .D    moveq    #dlt_device,d1
  10857.     bsr    find_next_assign    walk through dos-list
  10858.     tst.l    d0
  10859.     bne.s    .C
  10860.     move.l    8(a0),packettask(a5)    task
  10861.     beq.s    .D        was non-disk-device
  10862.     bsr    GetDiskInfo
  10863.     move.l    id_InUse(a5),d0    lock
  10864.     beq.s    .D
  10865. .A    addq.l    #1,d3    count locks
  10866.     movem.l    d0-d3/a0-a2,-(sp)
  10867.     moveq    #0,d7
  10868.     bsr    ShowLock    show lock
  10869.     movem.l    (sp)+,d0-d3/a0-a2
  10870.     lsl.l    #2,d0
  10871.     move.l    d0,a0
  10872.     move.l    (a0),d0
  10873.     bne.s    .A
  10874.     bra.s    .D
  10875. .C    move.l    d3,-(sp)
  10876.     move.l    sp,a1
  10877.     lea    numoflocks(pc),a0
  10878.     bsr    new_print
  10879.     addq.l    #4,sp
  10880. LockOK    moveq    #RETURN_OK,d0
  10881.     rts
  10882.  
  10883. GetDiskInfo    ;device-task must be in packettask(a5), gets info to a5
  10884.     bsr    clearArgs
  10885.     moveq    #ACTION_DISK_INFO,d0
  10886.     move.l    d0,packettype(a5)
  10887.     move.l    a5,d0
  10888.     lsr.l    #2,d0
  10889.     move.l    d0,myArg1(a5)    use FIB as INFO (bptr)
  10890.     bra    sendpacket
  10891.  
  10892. *************************
  10893. *    RUN        *    V2.2
  10894. *************************
  10895. runz    clr.l    temp4(a5)
  10896.     tst.b    redirect_out(a5)
  10897.     beq.s    .B
  10898.     tst.l    MPipePtr(a5)
  10899.     bne.s    .B
  10900.     tst.b    pipe_out(a5)
  10901.     bne.s    .B
  10902.     move.l    thistask(a5),a0
  10903.     move.l    pr_COS(a0),temp4(a5)
  10904.     move.l    stdout(a5),pr_COS(a0)    restore old stdout
  10905.     move.l    stdout(a5),outhandle(a5)    
  10906. .B    clr.b    redirect_out(a5)
  10907.     clr.l    parm4(a5)
  10908.     bsr    ConvertSemi
  10909.     lea    tempbuf(a5),a0
  10910.     move.l    a0,parm2(a5)
  10911.     move.l    #"-w*"<<8,(a0)+
  10912.     move.l    a0,parm3(a5)
  10913.     move.w    #'-c',(a0)+
  10914.     lea    CLIbuf(a5),a1
  10915. .A    move.b    (a1)+,(a0)+    copy CLIbuf
  10916.     bne.s    .A
  10917.     moveq    #2,d7
  10918.     bra.s    create_new_cli
  10919.  
  10920. *************************
  10921. *    NewCLI        *    V2.0
  10922. *************************
  10923. newcliz    moveq    #1,d7
  10924. create_new_cli        ;ENTRY: d7=Mode
  10925.     lea    ZShellName(pc),a0
  10926.     move.l    a0,d1        process-name
  10927.     move.l    thistask(a5),a0
  10928.     moveq    #0,d2        priority
  10929.     move.b    LN_PRI(a0),d2
  10930.     lea    start-4(pc),a0
  10931.     move.l    a0,d3        
  10932.     lsr.l    #2,d3        seglist
  10933.     move.l    #4000,d4    stacksize
  10934.     jsr    _LVOCreateProc(a6)
  10935.     tst.l    d0
  10936.     beq.s    .B
  10937.     move.l    d0,a4        a4:new process
  10938.     moveq    #$24,d0
  10939.     move.l    #MEMF_CLEAR+1,d1    memory for Message
  10940.     bsr    iwantmem
  10941.     beq.s    .B
  10942.     move.l    d0,a1        a1,a3:message
  10943.     move.l    a1,a3
  10944.     move.b    #5,LN_TYPE(a1)
  10945.     move.l    thistask(a5),a0
  10946.     lea    pr_MsgPort(a0),a2    a2:msgport of this task
  10947.     move.l    a2,mn_ReplyPort(a1)
  10948.     move.w    #$24,mn_Length(a1)
  10949.     move.l    a5,sm_NumArgs(a1)
  10950.     move.b    d7,sm_ToolWindow(a1)
  10951.     move.l    a4,a0
  10952.     move.l    4.w,a6
  10953.     jsr    _LVOPutMsg(a6)
  10954. .A    move.l    a2,a0
  10955.     jsr    _LVOWaitPort(a6)
  10956.     move.l    a2,a0
  10957.     jsr    _LVOGetMsg(a6)
  10958.     cmp.l    a3,d0
  10959.     bne    .A
  10960.     move.l    sm_ToolWindow(a3),-(sp)    return value
  10961. ;    move.l    dosbase(a5),a6
  10962.     move.l    d0,a1
  10963.     moveq    #$24,d0
  10964.     bsr    givemem
  10965.     move.l    (sp)+,d0
  10966.     rts
  10967. .B    moveq    #RETURN_ERROR,d0
  10968.     rts
  10969.  
  10970. *************************
  10971. *    TaskPri        *    V2.0
  10972. *************************
  10973. taskpriz bsr    fixpam32
  10974.     move.l    a1,a2
  10975.     move.l    a0,a1
  10976.     tst.b    (a1)
  10977.     beq    too_less_args
  10978.     bsr    convert_ASCII_to_num
  10979.     beq    bad_number_error
  10980.     move.l    d0,d7
  10981.     bsr    findtsk
  10982.     beq    pr_notfound
  10983.     move.l    a0,a1
  10984.     move.b    d7,d0
  10985.     move.l    4.w,a6
  10986.     jsr    _LVOSetTaskPri(a6)
  10987. tskok    move.l    dosbase(a5),a6
  10988.     moveq    #RETURN_OK,d0
  10989.     rts
  10990.  
  10991. * Find Task given in a2 (ptr,string,cli-number,null)
  10992. * RETURN: d0,a0 address (0 if not found)
  10993. findtsk    move.l    a2,a1
  10994.     moveq    #0,d0
  10995.     tst.b    (a1)
  10996.     beq.s    .E
  10997.     bsr    convert_ASCII_to_num
  10998.     beq.s    .C
  10999. .E    cmp.l    #20,d0
  11000.     bhi.s    .A        is address
  11001.     move.l    d0,a1
  11002.     tst.l    d0        0 means own task
  11003.     beq.s    .D
  11004.     lsl.l    #2,d0        is a cli-number
  11005.     move.l    dl_Root(a6),a0
  11006.     move.l    (a0),a0
  11007.     add.l    a0,a0
  11008.     add.l    a0,a0
  11009.     add.l    d0,a0
  11010.     move.l    (a0),d0
  11011.     beq.s    .B
  11012.     sub.l    #pr_MsgPort,d0
  11013.     bra.s    .A
  11014. .C    move.l    a2,a1
  11015. .D    move.l    4.w,a6
  11016.     jsr    _LVOFindTask(a6)    search name
  11017.     move.l    dosbase(a5),a6
  11018. .A    tst.l    d0
  11019.     beq.s    .B
  11020.     move.l    d0,a0
  11021.     cmp.b    #01,LN_TYPE(a0)    is it a TASK-struct ?
  11022.     beq.s    .B
  11023.     cmp.b    #13,LN_TYPE(a0)    is it a PROCESS-struct ?
  11024.     beq.s    .B
  11025.     moveq    #0,d0
  11026. .B    tst.l    d0
  11027.     rts
  11028.  
  11029. *************************
  11030. *    Break        *    V2.0
  11031. *************************
  11032. breakz    bsr    fixpam32
  11033.     move.l    a0,a2
  11034.     move.l    a1,a3
  11035.     tst.b    (a2)
  11036.     beq    too_less_args
  11037.     bsr    findtsk
  11038.     beq    pr_notfound
  11039.     move.l    a3,a1
  11040.     move.l    a0,a2
  11041.     tst.b    (a1)
  11042.     beq.s    .B
  11043.     bsr    convert_ASCII_to_num
  11044.     bne.s    .C
  11045.     moveq    #RETURN_ERROR,d0
  11046.     move.b    (a3),d1
  11047.     bclr    #5,d1
  11048.     cmp.b    #"C",d1
  11049.     blo.s    .A
  11050.     cmp.b    #"F",d1
  11051.     bhi.s    .A
  11052.     sub.b    #55,d1
  11053.     moveq    #0,d0
  11054.     bset    d1,d0
  11055.     bra.s    .C
  11056. .B    move.l    tc_SigWait(a2),d0
  11057. .C    move.l    a2,a1
  11058.     move.l    4.w,a6
  11059.     jsr    _LVOSignal(a6)    set signals given in mask
  11060.     move.l    dosbase(a5),a6
  11061.     moveq    #RETURN_OK,d0
  11062. .A    rts
  11063.  
  11064. *************************
  11065. *    PutMsg        *    V2.0
  11066. *************************
  11067. putmsgz    move.l    parm2(a5),d7
  11068.     beq    printa5
  11069.     move.l    d7,a1
  11070.     bsr    convert_ASCII_to_num
  11071.     bne.s    .D
  11072.     move.l    d7,a1
  11073.     move.l    4.w,a6
  11074.     jsr    _LVOFindPort(a6)    search name
  11075.     move.l    dosbase(a5),a6
  11076.     tst.l    d0
  11077.     beq.s    .B
  11078.     move.l    d0,a0
  11079.     bra.s    .E
  11080. .D    move.l    d0,a0
  11081.     cmp.l    #20,d0
  11082.     bls.s    .B
  11083.     cmp.b    #04,LN_TYPE(a0)    is it a MSGPORT-struct ?
  11084.     beq.s    .E
  11085. .B    move.l    d7,a2
  11086.     bsr    findtsk        search task
  11087.     bne.s    .C
  11088. .A    bra    pr_notfound
  11089. .C    cmp.b    #13,LN_TYPE(a0)    is it a PROCESS-struct ?
  11090.     bne.s    .A
  11091.     lea    pr_MsgPort(a0),a0
  11092. .E    bsr    clearArgs
  11093.     move.l    thistask(a5),a2
  11094.     lea    pr_MsgPort(a2),a2
  11095.     move.l    a2,sp_reply(a5)
  11096.     move.b    #5,LN_TYPE+sp_node(a5)
  11097.     lea    parm3(a5),a2
  11098.     lea    sp_link(a5),a3
  11099.     moveq    #mn_Size,d2
  11100. .G    move.l    (a2)+,d3
  11101.     beq.s    .F
  11102.     move.l    d3,a1
  11103.     bsr    convert_ASCII_to_num
  11104.     bne.s    .H
  11105.     move.l    d3,d0
  11106. .H    move.l    d0,(a3)+
  11107.     addq.w    #4,d2
  11108.     bra.s    .G
  11109. .F    move.w    d2,sp_length(a5)
  11110.     move.l    sp_link(a5),a1
  11111.     move.b    (a1),d0
  11112.     cmp.b    dotchar(a5),d0
  11113.     bne.s    .I
  11114.     lea    sp_link(a5),a1        for DOSpackets
  11115.     move.l    a1,LN_NAME+sp_node(a5)
  11116.     lea    sp_node(a5),a1
  11117.     move.l    a1,sp_link(a5)
  11118.     move.l    sp_reply(a5),sp_port(a5)
  11119. .I    lea    msendtx(pc),a1
  11120.     bsr    pr_stringlf
  11121.     lea    sp_node(a5),a1        message
  11122.     move.l    4.w,a6
  11123.     jsr    _LVOPutMsg(a6)
  11124.     move.l    dosbase(a5),a6
  11125.     clr.l    parm2(a5)
  11126.     bra.s    getmsg1
  11127.  
  11128. *************************
  11129. *    GetMsg        *    V2.0
  11130. *************************
  11131. getmsgz    moveq    #0,d7
  11132.     moveq    #0,d6
  11133.     move.l    parm2(a5),d2
  11134.     beq.s    getmsg1
  11135.     move.l    d2,a1
  11136.     move.l    4.w,a6
  11137.     jsr    _LVOFindPort(a6)    does it already exist ?
  11138.     tst.l    d0
  11139.     bne.s    getmsg1
  11140.     move.l    thistask(a5),a1
  11141.     lea    pr_MsgPort(a1),a1
  11142.     move.l    d2,LN_NAME(a1)
  11143.     jsr    _LVOAddPort(a6)
  11144.     moveq    #1,d6
  11145. getmsg1    move.l    thistask(a5),a2
  11146.     lea    pr_MsgPort(a2),a2
  11147.     move.l    4.w,a6
  11148.     move.l    a2,a0
  11149.     jsr    _LVOGetMsg(a6)
  11150.     tst.l    d0
  11151.     bne.s    .A
  11152.     moveq    #0,d2
  11153.     move.b    MP_SIGBIT(a2),d1
  11154.     bset    d1,d2
  11155.     bset    #SIGBREAKB_CTRL_C,d2
  11156.     move.l    d2,d1
  11157. ;    moveq    #0,d0
  11158.     jsr    _LVOSetSignal(a6)    clear signals
  11159.     move.l    d2,d0
  11160.     jsr    _LVOWait(a6)    wait for msgport or ctrl-c
  11161.     move.l    a2,a0
  11162.     jsr    _LVOGetMsg(a6)
  11163. .A    move.l    dosbase(a5),a6
  11164.     tst.l    d0
  11165.     beq    msgfail
  11166.     move.l    d0,a2
  11167.     move.w    mn_Length(a2),d2
  11168.     move.w    d2,-(sp)
  11169.     move.l    a2,-(sp)
  11170.     lea    msgtx(pc),a0
  11171.     move.l    sp,a1
  11172.     bsr    new_print
  11173.     addq.l    #6,sp
  11174.     sub.w    #mn_Size,d2
  11175.     lsr.w    #2,d2
  11176.     lea    mn_Size(a2),a3
  11177.     bra.s    .D
  11178. .C    move.l    (a3)+,d0
  11179.     cmp.l    #$dfe000,d0
  11180.     bhs.s    .E
  11181.     cmp.l    #$a00000,d0
  11182.     blo.s    .F
  11183.     cmp.l    #$c00000,d0
  11184.     blo.s    .E
  11185. .F    move.l    d0,a0
  11186.     moveq    #79,d1
  11187. .H    move.b    (a0)+,d3
  11188.     beq.s    .G
  11189.     cmp.b    #" ",d3
  11190.     blo.s    .E
  11191.     cmp.b    #"~",d3
  11192.     bhi.s    .E
  11193.     dbra    d1,.H
  11194.     bra.s    .E
  11195. .G    cmp.w    #76,d1
  11196.     bhs.s    .E
  11197.     bsr    printADR
  11198.     bsr    pr_space
  11199.     move.l    d0,a1
  11200.     bsr    pr_stringlf
  11201.     bra.s    .D
  11202. .E    bsr    printADR
  11203.     bsr    pr_lf
  11204. .D    dbra    d2,.C
  11205.     tst.l    d7
  11206.     bne.s    .B
  11207.     tst.l    d6
  11208.     beq.s    .I
  11209.     move.l    thistask(a5),a1
  11210.     lea    pr_MsgPort(a1),a1
  11211.     move.l    4.w,a6
  11212.     jsr    _LVORemPort(a6)
  11213.     move.l    dosbase(a5),a6
  11214. .I    lea    replytx(pc),a1
  11215.     bsr    pr_string
  11216.     bsr    rask
  11217.     move.l    d0,d2
  11218.     beq.s    .B
  11219.     move.l    4.w,a6
  11220.     move.l    a2,a1
  11221.     jsr    _LVOReplyMsg(a6)
  11222.     move.l    dosbase(a5),a6
  11223.     cmp.b    #RETURN_ERROR,d2
  11224.     beq    getmsg1
  11225. .B    moveq    #RETURN_OK,d0
  11226.     rts
  11227. printa5    move.l    a5,-(sp)
  11228.     move.l    sp,a1
  11229.     lea    pra5tx(pc),a0
  11230.     bsr    new_print
  11231.     addq.l    #4,sp
  11232.     bsr    DisplayBeep
  11233. msgfail    moveq    #RETURN_ERROR,d0
  11234.     rts
  11235.  
  11236. *************************
  11237. *    Border        *    V2.0
  11238. *************************
  11239. wd_BorderLeft    equ    54
  11240. wd_Flags    equ    24
  11241.  
  11242. borderz    move.l    parm2(a5),a0
  11243.     bsr    CheckOnOff
  11244.     move.l    d0,-(sp)
  11245.     bsr    GetWindowPtr
  11246.     beq    nosiz
  11247.     move.l    d0,a0
  11248.     move.l    a0,a4        this window
  11249.     move.l    intuibase(a5),a6
  11250.     moveq    #0,d0
  11251.     jsr    _LVOLockIBase(a6)
  11252.     move.l    d0,d7
  11253.     move.l    (sp)+,d0
  11254.     beq    bordoff
  11255.  
  11256. bordon    tst.l    bordersize(a5)
  11257.     beq.s    borne
  11258.     bclr    #11,wd_Flags+2(a4)    unset noborder
  11259.     move.l    bordersize(a5),wd_BorderLeft(a4)
  11260.     bra.s    borjo
  11261.  
  11262. bordoff    tst.l    wd_BorderLeft(a4)
  11263.     beq.s    borjo
  11264.     bset    #11,wd_Flags+2(a4)    set noborder-window
  11265.     move.l    wd_BorderLeft(a4),bordersize(a5)
  11266.     clr.l    wd_BorderLeft(a4)
  11267. borjo    moveq    #$00,d0        null resize
  11268.     moveq    #$00,d1
  11269.     move.l    a4,a0
  11270.     jsr    _LVOSizeWindow(a6)
  11271.     move.l    a4,a0
  11272.     jsr    _LVORefreshWindowFrame(a6)    redraw
  11273. borne    move.l    d7,a0
  11274.     jsr    _LVOUnlockIBase(a6)
  11275.     move.l    parm3(a5),d0
  11276.     beq.s    nosiz
  11277.     move.l    d0,a1
  11278.     bsr    convert_ASCII_to_num
  11279.     tst.l    d1
  11280.     beq.s    nosiz
  11281.                 ;resize window to fill screen
  11282.     move.l    $2e(a4),a1    points to screen
  11283.     move.l    d0,d4    width of menubar
  11284.     bpl.s    .A
  11285.     moveq    #0,d4
  11286.     move.b    30(a1),d4
  11287.     add.b    31(a1),d4
  11288. .A    moveq    #-1,d2
  11289.     move.l    12(a1),d3
  11290.     sub.w    10(a4),d3
  11291.     sub.w    d4,d3
  11292.     move.w    d3,d1
  11293.     bpl.s    bklein
  11294.     moveq    #0,d2
  11295.     moveq    #0,d0
  11296.     move.l    a4,a0
  11297.     jsr    _LVOSizeWindow(a6)
  11298. bklein    moveq    #0,d0
  11299.     sub.w    4(a4),d0
  11300.     move.l    d4,d1
  11301.     sub.w    6(a4),d1
  11302.     move.l    a4,a0
  11303.     jsr    _LVOMoveWindow(a6)
  11304.     moveq    #0,d1
  11305.     tst.b    d2
  11306.     beq.s    bgross
  11307.     move.w    d3,d1
  11308. bgross    swap    d3
  11309.     sub.w    8(a4),d3
  11310.     move.w    d3,d0
  11311.     move.l    a4,a0
  11312.     jsr    _LVOSizeWindow(a6)
  11313.     jsr    _LVORethinkDisplay(a6)
  11314.     
  11315. nosiz    move.l    dosbase(a5),a6
  11316.     moveq    #10,d1        wait more than 1/10 sec
  11317.     jsr    _LVODelay(a6)
  11318.     moveq    #RETURN_OK,d0
  11319.     rts
  11320.  
  11321. *************************
  11322. *    Review        *    V2.1
  11323. *************************
  11324. reviewz    move.l    parm2(a5),d0
  11325.     beq.s    ShowReview
  11326.     move.l    d0,a1
  11327.     move.l    d0,a2
  11328.     bsr    convert_ASCII_to_num
  11329.     bne.s    MakeReview
  11330.     or.b    #$20,(a2)
  11331.     cmp.b    #"c",(a2)
  11332.     beq.s    ClearReview
  11333.     cmp.b    #"s",(a2)
  11334.     bne.s    ShowReview
  11335.     move.l    parm3(a5),d0        Save review-buffer
  11336.     beq    too_less_args
  11337.     tst    ReviewSize(a5)
  11338.     beq.s    ShowReview
  11339.     move.l    d0,a3
  11340.     bra    viewbuffer
  11341.  
  11342. ShowReview
  11343.     lea    ReviewSize(a5),a1    Show review-info
  11344.     bra    ShowBuffer
  11345.  
  11346. ClearReview
  11347.     move.l    ReviewMem(a5),a0
  11348.     move.l    ReviewSize(a5),d0
  11349.     move.l    d0,d1
  11350.     swap    d1
  11351.     bra.s    .D
  11352. .E    move.b    #" ",(a0)+    Fill with spaces
  11353. .D    dbra    d0,.E
  11354.     dbra    d1,.E
  11355.     move.b    #LF,-1(a0)    Last char is LF
  11356.     clr.l    ReviewPtr(a5)
  11357.     moveq    #RETURN_OK,d0
  11358.     rts
  11359.  
  11360. MakeReview
  11361.     tst.l    d0            Add review-buffer
  11362.     beq    reviewend
  11363.     tst.l    ReviewSize(a5)
  11364.     beq.s    .F
  11365.     move.l    d0,-(sp)
  11366.     bsr    reviewend
  11367.     move.l    (sp)+,d0
  11368. .F    move.l    d0,d2
  11369.     moveq    #1,d1
  11370.     bsr    iwantmem
  11371.     beq    ShowReview
  11372.     move.l    d0,ReviewMem(a5)
  11373.     move.l    d2,ReviewSize(a5)
  11374.     bsr    ClearReview
  11375.     clr.l    ReviewPtr(a5)
  11376.     clr.b    noreview_flag(a5)
  11377.     lea    RHa3(pc),a3        Look for a5-Table
  11378.     tst.l    (a3)
  11379.     bne.s    entryA5
  11380.     moveq    #80,d0
  11381.     move.l    #1+1<<16,d1        "memf_public" & clear it
  11382.     bsr    iwantmem
  11383.     beq    reviewend
  11384.     move.l    d0,(a3)
  11385. APatch    moveq    #_LVOWrite,d2        Add review-patch to DOS Write
  11386.     move.w    #$4ef9,d3
  11387.     move.l    a6,a2
  11388.     add.l    d2,a2
  11389.     moveq    #0,d1
  11390.     cmp.w    (a2),d3
  11391.     bne.s    .B
  11392.     move.l    2(a2),a0
  11393.     lea    RCode(pc),a1
  11394.     cmp.l    a1,a0
  11395.     beq.s    entryA5
  11396.     moveq    #-1,d1
  11397.     bra.s    .C
  11398. .B    cmp.w    #$6000,2(a2)
  11399.     bne.s    reviewend
  11400. .C    movem.l    d0-d1/a0-a1,-(sp)
  11401.     bsr    do_forbid
  11402.     movem.l    (sp)+,d0-d1/a0-a1
  11403.     lea    RHa1(pc),a1
  11404.     move.w    (a2),(a1)
  11405.     move.l    2(a2),2(a1)
  11406.     tst.w    d1
  11407.     bne.s    .D
  11408.     lea    4(a2),a0
  11409.     move.w    (a0),d0
  11410.     ext.l    d0
  11411.     add.l    d0,a0
  11412.     move.l    a0,4(a1)
  11413.     move.w    d3,2(a1)
  11414. .D    lea    RCode(pc),a0
  11415.     move.w    d3,(a2)
  11416.     move.l    a0,2(a2)
  11417.     bsr    do_permit
  11418. entryA5    move.l    (a3),a3            Add a5-table entry
  11419.     moveq    #20-1,d0
  11420. .F    tst.l    (a3)+
  11421.     beq.s    .G
  11422.     dbra    d0,.F
  11423.     bra    reviewend
  11424. .G    move.l    a5,-4(a3)
  11425.     bra    reviewOK
  11426.  
  11427. reviewend        ;Remove review-buffer
  11428.     move.l    RHa3(pc),d0        Remove a5-table entry
  11429.     beq.s    remmem2
  11430.     move.l    d0,a0
  11431.     move.l    a0,a1
  11432.     move.l    a0,a2
  11433.     moveq    #20-1,d0
  11434. .A    cmp.l    (a0)+,a5
  11435.     beq.s    .B
  11436.     dbra    d0,.A
  11437.     bra.s    .D
  11438. .B    clr.l    -4(a0)
  11439. .D    moveq    #20-1,d0    look for other entries
  11440. .C    tst.l    (a2)+
  11441.     bne.s    remmem2
  11442.     dbra    d0,.C
  11443.     bsr    do_forbid
  11444.     lea    RHa3(pc),a0
  11445.     clr.l    (a0)
  11446.     moveq    #80,d0        last entry
  11447.     bsr    givemem
  11448.     moveq    #_LVOWrite,d0        Remove DOS Write Patch
  11449.     move.l    a6,a3
  11450.     add.l    d0,a3
  11451.     move.l    2(a3),a0
  11452.     lea    RCode(pc),a1
  11453.     cmp.l    a0,a1
  11454.     bne.s    remmem
  11455.     lea    RHa1(pc),a1
  11456.     move.w    (a1),(a3)
  11457.     move.l    2(a1),2(a3)
  11458.     cmp.w    #$4ef9,(a1)
  11459.     beq.s    remmem
  11460.     move.w    #$6000,2(a3)
  11461.     lea    4(a3),a2
  11462.     move.l    4(a1),d0
  11463.     sub.l    a2,d0
  11464.     move.w    d0,(a2)
  11465. remmem    bsr    do_permit
  11466. remmem2    move.l    ReviewSize(a5),d0    Remove buffer-memory
  11467.     beq.s    reviewOK
  11468.     move.l    ReviewMem(a5),a1
  11469.     bsr    givemem
  11470.     clr.l    ReviewSize(a5)
  11471. reviewOK
  11472.     moveq    #RETURN_OK,d0
  11473.     rts
  11474.  
  11475. viewbuffer        ;Show the review-buffer using more
  11476.     move.l    ReviewMem(a5),a2
  11477.     move.l    ReviewPtr(a5),d3
  11478.     move.l    ReviewSize(a5),d2
  11479.     bne.s    viewhist
  11480.     rts
  11481. viewhist    ;;Show a circular buffer using more
  11482.     move.l    d2,d4
  11483.     move.l    MPipePtr(a5),d1
  11484.     beq.s    .A
  11485.     move.l    d3,d0    for redirecting to more
  11486.     move.l    d1,d3
  11487.     sub.l    d0,d1
  11488.     bpl.s    .C
  11489.     add.l    d2,d1
  11490.     bra.s    .C
  11491. .A
  11492. .I    move.b    0(a2,d3.l),d0
  11493.     addq.l    #1,d3
  11494.     cmp.l    d3,d2
  11495.     bhi.s    .B
  11496.     clr.l    d3
  11497. .B    addq.l    #1,d1
  11498.     cmp.b    #LF,d0
  11499.     beq.s    .C
  11500.     cmp.b    #12,d0
  11501.     bne.s    .I
  11502. .C    sub.l    d1,d2
  11503.     move.l    d2,d0
  11504.     beq.s    reviewOK
  11505.     moveq    #1,d1
  11506.     bsr    iwantmem
  11507.     beq.s    reviewOK
  11508.     move.l    d0,a0
  11509.     move.l    a0,a1
  11510.     move.l    d4,d1
  11511.     move.l    d2,d4
  11512.     move.l    d2,d5
  11513.     swap    d5
  11514.     bra.s    .E
  11515. .D    move.b    0(a2,d3.l),d0
  11516.     cmp.b    #12,d0
  11517.     bne.s    .G
  11518.     move.b    #LF,d0
  11519. .G    cmp.b    #"c",d0
  11520.     bne.s    .H
  11521.     cmp.b    #27,-1(a0)
  11522.     bne.s    .H
  11523.     move.b    #LF,-1(a0)
  11524.     move.b    #LF,d0
  11525. .H    move.b    d0,(a0)+
  11526.     addq.l    #1,d3
  11527.     cmp.l    d3,d1
  11528.     bhi.s    .E
  11529.     clr.l    d3
  11530. .E    dbra    d2,.D
  11531.     dbra    d5,.D
  11532.     move.l    a3,d0
  11533.     bne.s    viewwrite
  11534.     move.l    a1,d0
  11535.     move.l    d4,d1
  11536.     moveq    #-1,d2
  11537.     tst.l    MPipePtr(a5)
  11538.     beq.s    .F
  11539.     moveq    #0,d2
  11540. .F    moveq    #0,d4
  11541.     bra    ViewMore
  11542. viewwrite        ;write buffer to file
  11543.     move.l    a1,a2
  11544.     move.l    a3,d1
  11545.     move.l    #MODE_NEWFILE,d2
  11546.     jsr    _LVOOpen(a6)
  11547.     tst.l    d0
  11548.     beq.s    .A
  11549.     move.l    d0,a3
  11550.     move.l    a3,d1
  11551.     move.l    a2,d2
  11552.     move.l    d4,d3
  11553.     move.l    d3,-(sp)
  11554.     jsr    _LVOWrite(a6)
  11555.     move.l    (sp)+,d3
  11556.     sub.l    d0,d3
  11557.     move.l    a3,d1
  11558.     jsr    _LVOClose(a6)
  11559.     moveq    #1,d0
  11560.     tst.l    d3
  11561.     beq.s    .A
  11562.     moveq    #0,d0
  11563. .A    move.l    d0,d2
  11564.     move.l    d4,d0
  11565.     move.l    a2,a1
  11566.     bsr    givemem
  11567.     tst.l    d2
  11568.     beq    DOSerr
  11569.     bra    reviewOK
  11570.  
  11571.     
  11572.  
  11573. *****    ReviewHandler    ********
  11574. RHa1    dc.w    $4ef9    JMP
  11575. RHa2    dcb.w    3,0    Return-Code
  11576. RHa3    dcb.l    1,0    Memory-Base-Table
  11577.  
  11578. RCode    movem.l    d0-d3/a5-a6,-(sp)    ;Is called by the DOS Write fkt.
  11579.     move.l    RHa3(pc),d0
  11580.     beq.s    .C
  11581.     move.l    d0,a0
  11582.     moveq    #20-1,d0
  11583. .B    move.l    (a0)+,a5
  11584.     cmp.l    outhandle(a5),d1    same outhandle ?
  11585.     bne.s    .D
  11586.     tst.b    redirect_out(a5)    not output-redirected ?
  11587.     beq.s    .A
  11588.     tst.l    MPipePtr(a5)        or review to MORE ?
  11589.     bne.s    .A
  11590. .D    dbra    d0,.B
  11591.     bra.s    .C
  11592. .A    tst.b    noreview_flag(a5)
  11593.     bne.s    .C
  11594.     bsr    toreview
  11595. .C    movem.l    (sp)+,d0-d3/a5-a6
  11596.     bra.s    RHa1
  11597.  
  11598. toreview    ;Writes data to review-buffer,Entry: d2=Adress, d3=Length
  11599.     move.l    d2,a0
  11600.     move.l    ReviewMem(a5),a1
  11601.     move.l    ReviewPtr(a5),d1
  11602.     move.l    ReviewSize(a5),d2
  11603.     beq.s    .C
  11604.     move.l    d3,d0
  11605.     swap    d0
  11606.     bra.s    .B
  11607. .A    move.b    (a0)+,0(a1,d1.l)
  11608.     addq.l    #1,d1
  11609.     cmp.l    d1,d2
  11610.     bhi.s    .B
  11611.     clr.l    d1
  11612. .B    dbra    d3,.A
  11613.     dbra    d0,.A
  11614.     move.l    d1,ReviewPtr(a5)
  11615. .C    rts
  11616.  
  11617.  
  11618. **********************************************************************
  11619. ; check if string in a0 is same as in a1 (limited by null,comma,space)
  11620. ; return: d0=0 for match, 1 otherwise
  11621. CheckOpt
  11622.     move.l    a0,-(sp)
  11623.     moveq    #1,d0
  11624.     cmp.b    #$22,-1(a0)    options are not enclosed in quotes
  11625.     beq.s    .D
  11626. .A    move.b    (a1)+,d1    compare things
  11627.     beq.s    .B
  11628.     cmp.b    #" ",d1
  11629.     beq.s    .B
  11630.     cmp.b    #",",d1
  11631.     beq.s    .B
  11632.     move.b    (a0)+,d0
  11633.     beq.s    .H
  11634.     cmp.b    dotchar(a5),d0    check for .
  11635.     bne.s    .F
  11636.     tst.b    (a0)
  11637.     beq.s    .G
  11638. .F    bsr    compD1D0nocase
  11639.     beq.s    .A
  11640. .H    moveq    #1,d0        failed (not matched)
  11641.     bra.s    .E
  11642. .G    moveq    #0,d0        success    (abbreviated)
  11643. .E    move.b    (a1)+,d1    search for end
  11644.     beq.s    .D
  11645.     cmp.b    #" ",d1
  11646.     beq.s    .D
  11647.     cmp.b    #",",d1
  11648.     bne.s    .E
  11649.     bra.s    .D
  11650. .B    moveq    #1,d0        success or a0 is too long ?
  11651.     tst.b    (a0)
  11652.     bne.s    .D
  11653.     moveq    #0,d0        length is same -> success
  11654. .D    move.l    (sp)+,a0
  11655.     tst.l    d0
  11656.     rts
  11657.  
  11658. *************************
  11659. ; check a0 for ON (d0=1) or OFF (d0=0) option, otherwise error-exit
  11660. CheckOnOff
  11661.     move.l    a2,-(sp)
  11662.     lea    onoffuse(pc),a2
  11663.     move.l    a0,d0
  11664.     beq.s    .B
  11665.     lea    6(a2),a1
  11666.     bsr    CheckOpt
  11667.     beq.s    .A
  11668.     move.l    a2,a1
  11669.     bsr    CheckOpt
  11670.     bne.s    .B
  11671.     moveq    #1,d0
  11672. .A    move.l    (sp)+,a2
  11673.     rts
  11674. .B    move.l    a2,a1
  11675. *************************
  11676. ; print error in a0 and exit
  11677. ErrorExit
  11678.     bsr    PrintError
  11679.     bra    galactic
  11680.  
  11681. *************************
  11682. ; check for Kickstart 2.0 or better, exit on error
  11683. CheckKS    lea    oldkick_tx(pc),a0
  11684.     cmp.w    #36,kickver(a5)
  11685.     blo.s    ErrorExit
  11686.     rts
  11687.  
  11688. **********************************************************************
  11689. ; check if option in a0 is in parm-list and deletes it from parm-list
  11690. ; return: d0=0 for match, 1 otherwise
  11691. LookForOpt
  11692.     movem.l    a2-a3,-(sp)
  11693.     move.l    a0,a2
  11694.     lea    parm2(a5),a3
  11695. .A    move.l    (a3)+,d0    search all parms
  11696.     beq.s    .B
  11697.     move.l    a2,a1
  11698.     move.l    d0,a0
  11699.     bsr    CheckOpt    look for option
  11700.     bne.s    .A
  11701.     lea    -4(a3),a2    found it !
  11702. .D    move.l    (a3)+,(a2)+    delete found parm
  11703.     bne.s    .D
  11704.     moveq    #0,d0
  11705.     bra.s    .C
  11706. .B    moveq    #1,d0        not found !
  11707. .C    movem.l    (sp)+,a2-a3
  11708.     rts
  11709.  
  11710. *************************
  11711. *    MakeLink    *    V2.3
  11712. *************************
  11713. makelinkz
  11714.     bsr    CheckKS
  11715.     moveq    #0,d7
  11716.     moveq    #0,d3
  11717.     move.l    parm4(a5),d0
  11718.     beq.s    .B
  11719.     move.l    d0,a0
  11720.     lea    softtx(pc),a1
  11721.     bsr    CheckOpt
  11722.     bne    SyntaxError
  11723.     moveq    #-1,d3
  11724. .B    move.l    parm3(a5),d1
  11725.     beq    too_less_args
  11726.     move.l    d1,d2
  11727.     tst.l    d3
  11728.     bne.s    .D
  11729.     moveq    #-2,d2
  11730.     jsr    _LVOLock(a6)
  11731.     move.l    d0,d7
  11732.     beq    DOSerr
  11733.     move.l    d0,d2
  11734. .D    move.l    parm2(a5),d1
  11735.     jsr    _LVOMakeLink(a6)
  11736.     tst.l    d0
  11737.     beq    DOSerrUL
  11738.     move.l    d7,d1
  11739.     beq.s    .A
  11740.     jsr    _LVOUnLock(a6)
  11741. .A    moveq    #RETURN_OK,d0
  11742.     rts
  11743.  
  11744. *************************
  11745. *    Flags        *    V2.3
  11746. *************************
  11747. flagsz    lea    parm2(a5),a3
  11748.     move.l    Flags(a5),d3
  11749.     tst.l    (a3)
  11750.     beq.s    .F
  11751. .A    move.l    d3,Flags(a5)
  11752.     move.l    (a3)+,d0
  11753.     beq.s    .C
  11754.     move.l    d0,a0
  11755.     lea    flagsuse(pc),a1
  11756.     moveq    #0,d2
  11757. .B    bsr    CheckOpt    look for flag
  11758.     beq.s    .D
  11759.     addq.w    #1,d2
  11760.     cmp.w    #MaxFlags,d2
  11761.     bne.s    .B
  11762.     lea    flagsuse(pc),a1
  11763.     bsr    pr_stringlf
  11764.     bra.s    .C
  11765. .D    move.l    (a3)+,a0    change flag
  11766.     bclr    d2,d3
  11767.     bsr    CheckOnOff
  11768.     beq.s    .A
  11769.     bset    d2,d3
  11770.     bra.s    .A
  11771.  
  11772. .F    moveq    #0,d2        print all flags
  11773.     lea    flagsuse(pc),a3
  11774. .E    lea    temp2buf(a5),a2
  11775. .G    move.b    (a3)+,d0
  11776.     move.b    d0,(a2)+
  11777.     cmp.b    #" ",d0
  11778.     beq.s    .H
  11779.     cmp.b    #",",d0
  11780.     bne.s    .G
  11781. .H    subq.l    #1,a2
  11782.     lea    flagsoff(pc),a1
  11783.     btst    d2,d3
  11784.     beq.s    .I
  11785.     lea    flagson(pc),a1
  11786. .I    bsr    addstring
  11787.     lea    temp2buf(a5),a1
  11788.     bsr    pr_string
  11789.     addq.w    #1,d2
  11790.     cmp.w    #MaxFlags,d2
  11791.     bne.s    .E
  11792. .C    moveq    #RETURN_OK,d0
  11793.     rts
  11794.  
  11795. *************************
  11796. *    MakeIcon    *    V2.3
  11797. *************************
  11798. makeiconz
  11799.     bsr    CheckKS
  11800.     move.l    parm2(a5),d3
  11801.     beq    too_less_args
  11802.     move.l    parm3(a5),d0
  11803.     beq.s    .E
  11804.     move.l    d0,a0
  11805.     moveq    #1,d2
  11806.     lea    iconuse(pc),a1
  11807. .D    bsr    CheckOpt
  11808.     beq.s    .C
  11809.     addq.l    #1,d2
  11810.     cmp.b    #9,d2
  11811.     bne.s    .D
  11812. .B    move.l    dosbase(a5),a6
  11813.     lea    iconuse(pc),a1
  11814.     bsr    pr_stringlf
  11815.     bra.s    .A
  11816. .C    bsr    OpenIconLib
  11817.     beq.s    .B
  11818.     move.l    d2,d0
  11819.     jsr    _LVOGetDefDiskObject(a6)
  11820.     move.l    d0,d2
  11821.     beq    resi_not_found
  11822.     move.l    d0,a1
  11823.     move.l    d3,a0
  11824.     jsr    _LVOPutDiskObject(a6)
  11825.     move.l    d0,d3
  11826.     move.l    d2,a0
  11827.     jsr    _LVOFreeDiskObject(a6)
  11828.     tst.l    d3
  11829.     beq    resi_not_found
  11830. .A    move.l    dosbase(a5),a6
  11831.     moveq    #RETURN_OK,d0
  11832.     rts
  11833.  
  11834. .E    ;shows icon using wb.lib's wbinfo
  11835.     cmp.w    #39,kickver(a5)        needs OS3.0+
  11836.     blo.s    .B
  11837.     bsr    OpenWBLib
  11838.     beq.s    .B
  11839.     move.l    thistask(a5),a0
  11840.     move.l    pr_CurrentDir(a0),a0
  11841.     move.l    parm2(a5),a1
  11842.     move.l    iconbase(a5),a2
  11843.     move.l    $38(a2),a2
  11844.     jsr    _LVOWBInfo(a6)
  11845.     bra.s    .A
  11846.  
  11847. *************************
  11848. *    Split        *    V2.6
  11849. *************************
  11850. splitz    tst.l    parm4(a5)
  11851.     beq    too_less_args
  11852.     moveq    #0,d5
  11853.     moveq    #0,d7        d7=current number
  11854.     clr.l    devproc(a5)
  11855.     clr.l    temp2(a5)
  11856.     bset    #19,temp2+1(a5)    split flag
  11857.     bsr    check_q_r
  11858.     move.l    parm4(a5),a1    get length
  11859.     bsr    convert_ASCII_to_num
  11860.     beq    bad_number_error
  11861.     move.l    d0,a3
  11862.     move.l    parm2(a5),d1
  11863.     move.l    #MODE_OLDFILE,d2
  11864.     jsr    _LVOOpen(a6)    open input file
  11865.     move.l    d0,d4        d4=input file handle
  11866.     beq    perr3
  11867.     move.l    parm5(a5),d0    may get offset
  11868.     beq.s    .A
  11869.     move.l    d0,a1
  11870.     bsr    convert_ASCII_to_num
  11871.     beq.s    .A
  11872.     move.l    d4,d1
  11873.     move.l    d0,d2
  11874.     moveq    #-1,d3
  11875.     jsr    _LVOSeek(a6)    skip offset
  11876. .A    bsr    GetCopyBlock
  11877.     beq.s    splend
  11878.  
  11879. sploop    move.l    parm3(a5),a0
  11880.     lea    tempbuf(a5),a1
  11881.     move.l    a1,d1
  11882. .A    move.b    (a0)+,(a1)+    copy output name
  11883.     bne.s    .A
  11884.     subq.l    #1,a1
  11885.     addq.l    #1,d7
  11886.     move.l    d7,d0
  11887.     bsr    qpr10        append number to name
  11888.     clr.b    (a1)
  11889.     move.l    d1,a1
  11890.     bsr    pr_string
  11891.     bsr    pr_space
  11892.     bsr    AskYesNo    ask
  11893.     beq.s    .B
  11894.     bsr    check_c
  11895.     bne.s    splend
  11896.     move.l    d4,d1
  11897.     move.l    a3,d2
  11898.     moveq    #0,d3
  11899.     jsr    _LVOSeek(a6)    skip part
  11900.     tst.l    d0
  11901.     bpl.s    sploop
  11902.     bra.s    splend
  11903.  
  11904. .B    move.l    #MODE_NEWFILE,d2
  11905.     jsr    _LVOOpen(a6)    open output file
  11906.     move.l    d0,d5        d5=output file handle
  11907.     bne.s    .D
  11908.     bsr    perr3
  11909.     bra.s    splend
  11910. .D    move.l    a3,d6        d6 holds filesize
  11911.     bsr    PerformCopy1    copy part to output
  11912.     bsr    check_c
  11913.     bne.s    splend
  11914.     tst.l    d0
  11915.     bne.s    .C
  11916.     lea    processOK(pc),a1    all OK
  11917.     bsr    pr_string
  11918. .C    moveq    #-1,d0
  11919.     cmp.l    d0,d6        check for input-fileend
  11920.     beq.s    sploop
  11921.  
  11922. splend    bsr    FreeCopyBlock
  11923.     move.l    d4,d1
  11924.     jsr    _LVOClose(a6)    close input
  11925.     moveq    #RETURN_OK,d0
  11926.     rts
  11927.  
  11928.  
  11929.  
  11930. manadr    dc.l    0    here are 2 global variables
  11931. mansize    dc.l    0    because the online-help-manual is used globally
  11932.  
  11933.  
  11934. recol1    dc.w    residetx+3-start,assign_tx+4-start,volume_tx+3-start
  11935.     dc.w    device1_tx+4-start,locktext+13-start
  11936.     dc.w    show_tx+2-start,show2_tx+2-start,shta_tx+2-start
  11937.     dc.w    proform+4-start,inform_tx+2-start,inform+24-start
  11938.     dc.w    inform2+15-start,stat_text+3-start,totsize+3-start
  11939.     dc.w    dirof+3-start,farb2+3-start,farb3+3-start
  11940.     dc.w    helpmor+3-start
  11941. recol2    ;Recolour-table to switch globally to one colour
  11942.     dc.b    2,2,2,2,3,2,2,2,3,2,7,5,7,7,6,2,3,2
  11943.  
  11944.  
  11945. * Localized Error-Messages
  11946. doserror_text
  11947.     dc.b     48,'*** BREAK ***',0        304
  11948.     dc.b     49,'Not executable',0        305
  11949.     dc.b    103,'Not enough Memory',0
  11950.     dc.b    108,'Too small',0        -148
  11951.     dc.b    115,'Bad number',0
  11952.     dc.b    116,'Not enough Arguments',0
  11953.     dc.b    135,'Command not found',0    -121
  11954.     dc.b    137,'Syntax Error',0        -119
  11955.     dc.b    202,'Object in use',0
  11956.     dc.b    203,'Object '
  11957. exists        dc.b    'exists',0
  11958.     dc.b    204,'Dir not found',0
  11959.     dc.b    205,'Object'
  11960. notfund        dc.b    ' not found',0
  11961.     dc.b    209,'Action unknown',0
  11962.     dc.b    210,'Invalid Name',0
  11963.     dc.b    212,'Object wrong Type',0
  11964.     dc.b    213,'Not validated',0
  11965.     dc.b    214,'Disk write-protected',0
  11966.     dc.b    215,'Rename across Devices',0  
  11967.     dc.b    216,'Dir not empty',0
  11968.     dc.b    218,'Device not mounted',0
  11969.     dc.b    221,'Disk full',0
  11970.     dc.b    222,'Delete protected',0
  11971.     dc.b    223,'Write protected',0
  11972.     dc.b    225,'Not a DOS Disk',0
  11973.     dc.b    226,'No Disk present',0
  11974.  
  11975.     dc.b    101,'Error %3ld',0        -155
  11976.     dc.b    102,'Failat: %ld',10,0        -154
  11977.     dc.b    104,'Current Dir',0        -152
  11978.     dc.b    110,'Stack: %ld bytes',10,0    -146
  11979.     dc.b    127,'ZShell Process %ld',10,0    -129
  11980.     dc.b    0,0
  11981.  
  11982.  
  11983. * Standard-Strings
  11984. iconname    dc.b    "icon.library",0
  11985. wbname        dc.b    "workbench.library",0
  11986. utilname    dc.b    "utility.library",0
  11987. aslname        dc.b    "asl.library",0
  11988. guidename    dc.b    "amigaguide.library",0
  11989. timdev        dc.b    "timer.device",0
  11990. conname        dc.b    "CON:0/10/640/190/ZShell V2.7/CLOSE",0
  11991. connil        dc.b    "NIL:",0
  11992. devpipe        dc.b    "PIPE:",0
  11993. devtemp        dc.b    "T:",0
  11994. wintool        dc.b    "WINDOW",0
  11995. screentool    dc.b    "SCREEN",0
  11996. scripttool    dc.b    "SCRIPT",0
  11997. norawtool    dc.b    "NORAW",0
  11998. commandtool    dc.b    "COMMAND",0
  11999. iconifytool    dc.b    "ICONIFY",0
  12000. xpostool    dc.b    "XPOS",0
  12001. ypostool    dc.b    "YPOS",0
  12002. nametool    dc.b    "ICONNAME",0
  12003. helptool    dc.b    "HELPMAN",0
  12004. wbenchtx    dc.b    "Workbench",0
  12005. useit        dc.b    "Usage: ZShell [-Wwindow] [-Sscript]"
  12006.         dc.b    " [-Ccommand] [-N] [-D]",0
  12007. onoffuse    dc.b    "ON or OFF ?",0
  12008. flagsuse    dc.b    "CHECK,MATCH,ICON,WILD,ERRORS,DEBUG"
  12009.         dc.b    ",CUT,ALL,HIDE,PIPE ?",0
  12010. iconuse        dc.b    "DISK,DRAWER,TOOL,PROJECT,GARBAGE"
  12011.         dc.b    ",DEVICE,KICK,APPICON ?",0
  12012. configuse    dc.b    "CTRLKEYS,MOREKEYS,DOT,HIDE,COLOUR"
  12013.         dc.b    ",COPYSIZE,FNCSIZE ?",0
  12014. assignuse    dc.b    "REMOVE,ADD,PATH,DEFER ?",0
  12015. softtx        dc.b    "SOFT",0
  12016. devicetx    dc.b    "DEVICE",0
  12017. forcetx        dc.b    "FORCE",0
  12018. alltx        dc.b    "ALL",0
  12019. defscript    dc.b    "S:ZStart",0    ;changed V2.0
  12020. rexxtx        dc.b    "REXX:RX",0
  12021. appicontx    dc.b    "Shell-It !",0
  12022. clkform        dc.b    ' Mem:%7ld Chip:%6ld  %02d:%02d:%02d ',0
  12023. warn_tx        dc.b    'warn',0
  12024. error_tx    dc.b    'error',0
  12025. fail_tx        dc.b    'fail',0
  12026. not_tx        dc.b    'not',0
  12027. oldkick_tx    dc.b    "Needs Kickstart 2.0+",0
  12028. redirtwice    dc.b    "Redirected twice",0
  12029. badprotbit    dc.b    'Unknown flag',0
  12030. noclk_tx    dc.b    'No Clock',0
  12031. stack_tx    dc.b    'Stack overflow',0
  12032. bytes_tx    dc.b    '%ld Bytes',10,0
  12033. residetx    dc.b    27,'[32mUsecount  Name',27,'[m',0
  12034. rpn_result_tx    dc.b    'RESULT: Dec %ld  Hex $%08lx',10,0
  12035. rpn_res2    dc.b    '%ld',0
  12036. unmounted_tx    dc.b    '[Un'
  12037. mounted_tx    dc.b    'Mounted]',0
  12038. assign_tx    dc.b    10,27,'[32mAssigns:',27,'[m',10,0
  12039. volume_tx    dc.b    27,'[32mVolumes:',27,'[m',10,0
  12040. device1_tx    dc.b    10,27,'[32m',0
  12041. device2_tx    dc.b    'Disk-'
  12042. device3_tx    dc.b    'Devices:',27,'[m',10,0
  12043. prompt_args_tx    dc.b    4,'%s> ',0
  12044. lockread    dc.b    'READ',0
  12045. lockwrite    dc.b    'WRITE',0
  12046. locktext    dc.b    '$%06lx: %s-Lock on ',$9b,'33m%s',$9b,'m',10,0
  12047. numoflocks    dc.b    '%ld locks',10,0
  12048. clk_tx        dc.b    'LOAD or SAVE ?',0
  12049. muell_tx    dc.b    'Format: DD.MM.YY or MM-DD-YY or HH:MM:SS',0
  12050. styp        dc.b    'lrdimps'
  12051. shuse_tx    dc.b    'Use D,I,L,M,P,R,S,T or V',0
  12052. show_tx        dc.b    $9b,'32mAdress Pri Name',$9b,'m',0
  12053. show2_tx    dc.b    $9b,'32mAdress Pri Ver Rev Name',$9b,'m',0
  12054. shform        dc.b    '%06lx%4d %s',10,0
  12055. shform2        dc.b    '%06lx%4d%4d%4d %s',10,0
  12056. shta_tx        dc.b    $9b,'32mAdress Pri State SignWait PT '
  12057.         dc.b    'Name',$9b,'m',0
  12058. shtaform    dc.b    '%06lx%4d %-5s %08lx %c%c %s',0
  12059. proform        dc.b    32,9,$9b,'33m->%sCLI %ld:',$9b,'m %s %s%s',0
  12060. backcli        dc.b    "Bg-",0
  12061. ttyp        dc.b    "Inval",0,"Added",0,"Run",0,"Ready",0
  12062.         dc.b    "Wait",0,"Exept",0,"Remov",0
  12063. inform_tx    dc.b    $9b,'32mName Unit Sys    Size    Free Full Block'
  12064.         dc.b    '   Status   Err  Volume',$9b,'m',0
  12065. inform        dc.b    '%-7s%2ld %3s%7ldK%7ldK',$9b,'37m%4ld%%',$9b
  12066.         dc.b    'm%6ld %-10s%3ld   %s',10,0
  12067. inform2        dc.b    '%-7s%2ld     ',$9b,'35m%s',$9b,'m',10,0
  12068. statro        dc.b    "Read only",0
  12069. statrw        dc.b    "Read/Write",0
  12070. statval        dc.b    "Validating",0
  12071. statun        dc.b    "Unknown",0
  12072. kickdisk    dc.b    "Kick",0
  12073. ofs_tx        dc.b    "OFS",0    OldFilesystem
  12074.         dc.b    "FFS",0    FastFilesystem
  12075.         dc.b    "OIN",0    International OFS
  12076.         dc.b    "FIN",0    International FFS
  12077.         dc.b    "ODC",0    Dir Cache OFS
  12078.         dc.b    "FDC",0 Dir Cache FFS
  12079. msd_tx        dc.b    "MSD",0    MessyDOS
  12080. quest_tx    dc.b    "???",0    Unknown
  12081. msendtx        dc.b    "sent",0
  12082. pra5tx        dc.b    "A5=%06lx",10,0
  12083. msgtx        dc.b    "Message=%06lx  Length=%d",10,0
  12084. time_text    dc.b    "Date: %02d.%02d.%02d    "
  12085.         dc.b    "Time: %02d:%02d:%02d.%02d",10,0
  12086. stat_text    dc.b    27,"[37mResult2=%ld  Time=%02d:%02d:%02d.%02d"
  12087.         dc.b    "  Changes-> Chip:%ld  Fast:%ld  Total:%ld"
  12088.         dc.b    27,"[m",10,0
  12089. lowmemtx    dc.b    "Changed %06lx: %08lx -> %08lx",10,0
  12090. replytx        dc.b    "Reply? ",0
  12091. mem_line    dc.b    "%08lx: %08lx %08lx %08lx %08lx   '%s'",10,0
  12092. vec_line    dc.b    "Warm $%08lx MemPtr $%08lx",10
  12093.         dc.b    "Cool $%08lx TagPtr $%08lx",10
  12094.         dc.b    "Cold $%08lx Check  $%08lx",10,0
  12095. formatask    dc.b    "Delete whole disk ? ",0
  12096. addbufftx    dc.b    "%s has %ld buffers",10,0
  12097. pfeil        dc.b    "-> ",0
  12098. flagsoff    dc.b    ": OFF",10,0
  12099. flagson        dc.b    ": ON",10,0
  12100. end_tx        dc.b    " end",0
  12101.  
  12102. format        dc.b    '%8ld',0    ;print a longw right justified
  12103. formatADR    dc.b    '$%06lx',0    ;print address 
  12104. totsize        dc.b    27,'[37mTotal Bytes: %ld  Blocks: %ld   '
  12105.         dc.b    'Files: %ld  Dirs: %ld',27,'[m',10,0
  12106. dirtext        dc.b    '(Dir)',27,'[m',0
  12107. dirof        dc.b    27,'[36mDirectory of ',27,'[m',0
  12108. paths        dc.b    "S:",0
  12109. msearch        dc.b    12,$9b,'BSearch: ',$9b," p",0
  12110. mjump        dc.b    12,$9b,'BJump to %: ',$9b," p",0
  12111. mwrite        dc.b    12,$9b,'BWrite to: ',$9b," p",0
  12112. wrongsize    dc.b    'New size:',0
  12113. makedirOK    dc.b    'created',10,0
  12114. copyOK        dc.b    'copied',10,0
  12115. moveOK        dc.b    'moved',10,0
  12116. processOK    dc.b    'processed',10,0
  12117. deleteOK    dc.b    'deleted',10,0
  12118. yesnotx        dc.b    'Yes/No/All/Quit ? ',0
  12119. memess        dc.b    "Chip: %ld  Fast: %ld  Total Free: %ld",10,0
  12120.  
  12121. star        dc.b    "*",0
  12122. dot        dc.b    ".",0
  12123. smaller        dc.b    "<",0
  12124. bigger        dc.b    ">",0
  12125. lf        dc.b    10,0
  12126. tab        dc.b    9,0
  12127. space        dc.b    " "
  12128. null        dc.b    0
  12129. help_ret    dc.b    "help^M",0
  12130. farb1        dc.b    27,'[m',0
  12131. farb2        dc.b    27,'[32m',0
  12132. farb3        dc.b    27,'[33m',0
  12133. backspace_it    dc.b    8        DON'T SEPERATE
  12134. delete_it    dc.b    $9b,'P',0        THESE LINES
  12135. return_it    dc.b    13,10,0
  12136. delete_line    dc.b    13,$9b,'M',0
  12137. clstx        dc.b    27,"c",0    reset console
  12138. clrtx        dc.b    12,0    clear screen
  12139. scroll_up_tx    dc.b    $9b,"S",13,0
  12140. scroll_down_tx    dc.b    $9b,"M",$9b,"T",$9b,"1H",0
  12141. clrhide        dc.b    12
  12142. hide_cursor    dc.b    $9b,"0 p",0
  12143. show_cursor    dc.b    $9b," p",0
  12144. askforsize    dc.b    $9b," q",0
  12145. cutontx        dc.b    $9b,"?7l",0
  12146. cutofftx    dc.b    $9b,"?7h",0
  12147.  
  12148. ctrl_init    dc.b    46,23,17,19,5,9,24,27,20,25,8,10,13,12,18,22,6,16
  12149. ctrl_inite        ;CTRL-Codes
  12150. more_init    dc.b    "ABCDSTqsnjwrh"    MORE keys
  12151. more_inite
  12152.  
  12153. helpld    dc.b    "Loading "
  12154. helpman    dc.b    "ZShell.doc",0
  12155. helpmor    dc.b    13,$9b,"32m %d%% %ld bytes. Use: (shift+)cursor,"
  12156.     dc.b    "(back)space,numeric,s,n,j,w,r,h",$9b,"K",$9b,"m",0
  12157.  
  12158.     end    ;***    here it ends    ***
  12159.  
  12160.